Loading include/ap_slotmem.h +8 −0 Changes for include/ap_slotmem.h: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -145,6 +145,14 @@ struct ap_slotmem_provider_t { * @return number of slots */ unsigned int (* num_slots)(ap_slotmem_instance_t *s); /** * return number of free (not used) slots allocated for this entry. * Valid for slots which are AP_SLOTMEM_TYPE_PREGRAB as well as * any which use get/release. * @param s ap_slotmem_instance_t to use. * @return number of slots */ unsigned int (* num_free_slots)(ap_slotmem_instance_t *s); /** * return slot size allocated for this entry. * @param s ap_slotmem_instance_t to use. Loading modules/slotmem/mod_slotmem_plain.c +14 −0 Changes for modules/slotmem/mod_slotmem_plain.c: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -181,6 +181,7 @@ static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, un if (ret != APR_SUCCESS) { return ret; } *inuse=1; memcpy(dest, ptr, dest_len); /* bounds check? */ return APR_SUCCESS; } Loading @@ -203,6 +204,7 @@ static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, un if (ret != APR_SUCCESS) { return ret; } *inuse=1; memcpy(ptr, src, src_len); /* bounds check? */ return APR_SUCCESS; } Loading @@ -212,6 +214,17 @@ static unsigned int slotmem_num_slots(ap_slotmem_instance_t *slot) return slot->num; } static unsigned int slotmem_num_free_slots(ap_slotmem_instance_t *slot) { unsigned int i, counter=0; char *inuse = slot->inuse; for (i=0; i<desc.num; i++, inuse++) { if (!*inuse) counter++; } return counter; } static apr_size_t slotmem_slot_size(ap_slotmem_instance_t *slot) { return slot->size; Loading Loading @@ -271,6 +284,7 @@ static const ap_slotmem_provider_t storage = { &slotmem_get, &slotmem_put, &slotmem_num_slots, &slotmem_num_free_slots &slotmem_slot_size, &slotmem_grab, &slotmem_release Loading modules/slotmem/mod_slotmem_shm.c +30 −6 Changes for modules/slotmem/mod_slotmem_shm.c: 30 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ typedef struct { apr_size_t size; /* size of each memory slot */ unsigned int num; /* number of mem slots */ unsigned int free; /* number of free mem slots */ ap_slotmem_type_t type; /* type-specific flags */ } sharedslotdesc_t; Loading Loading @@ -332,7 +333,7 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new, } ptr = (char *)apr_shm_baseaddr_get(shm); desc.size = item_size; desc.num = item_num; desc.free = desc.num = item_num; desc.type = type; memcpy(ptr, &desc, sizeof(desc)); ptr = ptr + AP_SLOTMEM_OFFSET; Loading @@ -341,8 +342,15 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new, * TODO: Error check the below... What error makes * sense if the restore fails? Any? */ if (type & AP_SLOTMEM_TYPE_PERSIST) if (type & AP_SLOTMEM_TYPE_PERSIST) { unsigned int i, counter=0; char *inuse = ptr + basesize; restore_slotmem(ptr, fname, dsize, pool); for (i=0; i<desc.num; i++, inuse++) if (!*inuse) counter++; desc.free = counter; } } /* For the chained slotmem stuff */ Loading Loading @@ -484,6 +492,7 @@ static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, if (ret != APR_SUCCESS) { return ret; } *inuse = 1; memcpy(dest, ptr, dest_len); /* bounds check? */ return APR_SUCCESS; } Loading @@ -507,6 +516,7 @@ static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, if (ret != APR_SUCCESS) { return ret; } *inuse=1; memcpy(ptr, src, src_len); /* bounds check? */ return APR_SUCCESS; } Loading @@ -516,15 +526,26 @@ static unsigned int slotmem_num_slots(ap_slotmem_instance_t *slot) return slot->desc.num; } static unsigned int slotmem_num_free_slots(ap_slotmem_instance_t *slot) { if (AP_SLOTMEM_IS_PREGRAB(slot)) return slot->desc.free; else { unsigned int i, counter=0; char *inuse = slot->inuse; for (i=0; i<slot->desc.num; i++, inuse++) { if (!*inuse) counter++; } return counter; } } static apr_size_t slotmem_slot_size(ap_slotmem_instance_t *slot) { return slot->desc.size; } /* * 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, unsigned int *id) { unsigned int i; Loading @@ -546,6 +567,7 @@ static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id) } *inuse = 1; *id = i; slot->desc.free--; return APR_SUCCESS; } Loading @@ -564,6 +586,7 @@ static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, return APR_NOTFOUND; } inuse[id] = 0; slot->desc.free++; return APR_SUCCESS; } Loading @@ -576,6 +599,7 @@ static const ap_slotmem_provider_t storage = { &slotmem_get, &slotmem_put, &slotmem_num_slots, &slotmem_num_free_slots, &slotmem_slot_size, &slotmem_grab, &slotmem_release Loading Loading
include/ap_slotmem.h +8 −0 Changes for include/ap_slotmem.h: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -145,6 +145,14 @@ struct ap_slotmem_provider_t { * @return number of slots */ unsigned int (* num_slots)(ap_slotmem_instance_t *s); /** * return number of free (not used) slots allocated for this entry. * Valid for slots which are AP_SLOTMEM_TYPE_PREGRAB as well as * any which use get/release. * @param s ap_slotmem_instance_t to use. * @return number of slots */ unsigned int (* num_free_slots)(ap_slotmem_instance_t *s); /** * return slot size allocated for this entry. * @param s ap_slotmem_instance_t to use. Loading
modules/slotmem/mod_slotmem_plain.c +14 −0 Changes for modules/slotmem/mod_slotmem_plain.c: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -181,6 +181,7 @@ static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, un if (ret != APR_SUCCESS) { return ret; } *inuse=1; memcpy(dest, ptr, dest_len); /* bounds check? */ return APR_SUCCESS; } Loading @@ -203,6 +204,7 @@ static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, un if (ret != APR_SUCCESS) { return ret; } *inuse=1; memcpy(ptr, src, src_len); /* bounds check? */ return APR_SUCCESS; } Loading @@ -212,6 +214,17 @@ static unsigned int slotmem_num_slots(ap_slotmem_instance_t *slot) return slot->num; } static unsigned int slotmem_num_free_slots(ap_slotmem_instance_t *slot) { unsigned int i, counter=0; char *inuse = slot->inuse; for (i=0; i<desc.num; i++, inuse++) { if (!*inuse) counter++; } return counter; } static apr_size_t slotmem_slot_size(ap_slotmem_instance_t *slot) { return slot->size; Loading Loading @@ -271,6 +284,7 @@ static const ap_slotmem_provider_t storage = { &slotmem_get, &slotmem_put, &slotmem_num_slots, &slotmem_num_free_slots &slotmem_slot_size, &slotmem_grab, &slotmem_release Loading
modules/slotmem/mod_slotmem_shm.c +30 −6 Changes for modules/slotmem/mod_slotmem_shm.c: 30 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ typedef struct { apr_size_t size; /* size of each memory slot */ unsigned int num; /* number of mem slots */ unsigned int free; /* number of free mem slots */ ap_slotmem_type_t type; /* type-specific flags */ } sharedslotdesc_t; Loading Loading @@ -332,7 +333,7 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new, } ptr = (char *)apr_shm_baseaddr_get(shm); desc.size = item_size; desc.num = item_num; desc.free = desc.num = item_num; desc.type = type; memcpy(ptr, &desc, sizeof(desc)); ptr = ptr + AP_SLOTMEM_OFFSET; Loading @@ -341,8 +342,15 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new, * TODO: Error check the below... What error makes * sense if the restore fails? Any? */ if (type & AP_SLOTMEM_TYPE_PERSIST) if (type & AP_SLOTMEM_TYPE_PERSIST) { unsigned int i, counter=0; char *inuse = ptr + basesize; restore_slotmem(ptr, fname, dsize, pool); for (i=0; i<desc.num; i++, inuse++) if (!*inuse) counter++; desc.free = counter; } } /* For the chained slotmem stuff */ Loading Loading @@ -484,6 +492,7 @@ static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, if (ret != APR_SUCCESS) { return ret; } *inuse = 1; memcpy(dest, ptr, dest_len); /* bounds check? */ return APR_SUCCESS; } Loading @@ -507,6 +516,7 @@ static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, if (ret != APR_SUCCESS) { return ret; } *inuse=1; memcpy(ptr, src, src_len); /* bounds check? */ return APR_SUCCESS; } Loading @@ -516,15 +526,26 @@ static unsigned int slotmem_num_slots(ap_slotmem_instance_t *slot) return slot->desc.num; } static unsigned int slotmem_num_free_slots(ap_slotmem_instance_t *slot) { if (AP_SLOTMEM_IS_PREGRAB(slot)) return slot->desc.free; else { unsigned int i, counter=0; char *inuse = slot->inuse; for (i=0; i<slot->desc.num; i++, inuse++) { if (!*inuse) counter++; } return counter; } } static apr_size_t slotmem_slot_size(ap_slotmem_instance_t *slot) { return slot->desc.size; } /* * 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, unsigned int *id) { unsigned int i; Loading @@ -546,6 +567,7 @@ static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id) } *inuse = 1; *id = i; slot->desc.free--; return APR_SUCCESS; } Loading @@ -564,6 +586,7 @@ static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, return APR_NOTFOUND; } inuse[id] = 0; slot->desc.free++; return APR_SUCCESS; } Loading @@ -576,6 +599,7 @@ static const ap_slotmem_provider_t storage = { &slotmem_get, &slotmem_put, &slotmem_num_slots, &slotmem_num_free_slots, &slotmem_slot_size, &slotmem_grab, &slotmem_release Loading