/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
/* Memory handler for a plain memory divided in slot. * This one uses plain memory.
*/
struct ap_slotmem_instance_t { char *name; /* per segment name */ void *base; /* data set start */
apr_size_t size; /* size of each memory slot */ unsignedint num; /* number of mem slots */
apr_pool_t *gpool; /* per segment global pool */ char *inuse; /* in-use flag table*/
ap_slotmem_type_t type; /* type-specific flags */ struct ap_slotmem_instance_t *next; /* location of next allocated segment */
};
/* global pool and list of slotmem we are handling */ staticstruct ap_slotmem_instance_t *globallistmem = NULL; static apr_pool_t *gpool = NULL;
if (name) { if (name[0] == ':')
fname = name; else
fname = ap_runtime_dir_relative(pool, name);
/* first try to attach to existing slotmem */ if (next) { for (;;) { if (strcmp(next->name, fname) == 0) { /* we already have it */
*new = next; return APR_SUCCESS;
} if (!next->next) { break;
}
next = next->next;
}
}
} else
fname = "anonymous";
/* create the memory using the gpool */
res = (ap_slotmem_instance_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_instance_t));
res->base = apr_pcalloc(gpool, basesize + (item_num * sizeof(char))); if (!res->base) return APR_ENOSHMAVAIL;
if (name) { if (name[0] == ':')
fname = name; else
fname = ap_runtime_dir_relative(pool, name);
} else return APR_ENOSHMAVAIL;
/* first try to attach to existing slotmem */ while (next) { if (strcmp(next->name, fname) == 0) { /* we already have it */
*new = next;
*item_size = next->size;
*item_num = next->num; return APR_SUCCESS;
}
next = next->next;
}
/* * XXXX: if !AP_SLOTMEM_IS_PREGRAB, then still worry about * inuse for grab and return?
*/ static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsignedint *id)
{ unsignedint i; char *inuse;
if (!slot) { return APR_ENOSHMAVAIL;
}
inuse = slot->inuse;
for (i = 0; i < slot->num; i++, inuse++) { if (!*inuse) { break;
}
} if (i >= slot->num) { return APR_EINVAL;
}
*inuse = 1;
*id = i; return APR_SUCCESS;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.