diff options
Diffstat (limited to 'modules/slotmem/mod_slotmem_plain.c')
-rw-r--r-- | modules/slotmem/mod_slotmem_plain.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/modules/slotmem/mod_slotmem_plain.c b/modules/slotmem/mod_slotmem_plain.c index 47da15b4..4c2b19b6 100644 --- a/modules/slotmem/mod_slotmem_plain.c +++ b/modules/slotmem/mod_slotmem_plain.c @@ -75,7 +75,7 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new, const char *name if (name[0] == ':') fname = name; else - fname = ap_server_root_relative(pool, name); + fname = ap_runtime_dir_relative(pool, name); /* first try to attach to existing slotmem */ if (next) { @@ -126,7 +126,7 @@ static apr_status_t slotmem_attach(ap_slotmem_instance_t **new, const char *name if (name[0] == ':') fname = name; else - fname = ap_server_root_relative(pool, name); + fname = ap_runtime_dir_relative(pool, name); } else return APR_ENOSHMAVAIL; @@ -154,7 +154,7 @@ static apr_status_t slotmem_dptr(ap_slotmem_instance_t *score, unsigned int id, if (!score) return APR_ENOSHMAVAIL; if (id >= score->num) - return APR_ENOSHMAVAIL; + return APR_EINVAL; ptr = (char *)score->base + score->size * id; if (!ptr) @@ -174,7 +174,10 @@ static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, un } inuse = slot->inuse + id; - if (id >= slot->num || (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse)) { + if (id >= slot->num) { + return APR_EINVAL; + } + if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) { return APR_NOTFOUND; } ret = slotmem_dptr(slot, id, &ptr); @@ -197,7 +200,10 @@ static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, un } inuse = slot->inuse + id; - if (id >= slot->num || (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse)) { + if (id >= slot->num) { + return APR_EINVAL; + } + if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) { return APR_NOTFOUND; } ret = slotmem_dptr(slot, id, &ptr); @@ -251,13 +257,29 @@ static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id) } } if (i >= slot->num) { - return APR_ENOSHMAVAIL; + return APR_EINVAL; } *inuse = 1; *id = i; return APR_SUCCESS; } +static apr_status_t slotmem_fgrab(ap_slotmem_instance_t *slot, unsigned int id) +{ + char *inuse; + + if (!slot) { + return APR_ENOSHMAVAIL; + } + + if (id >= slot->num) { + return APR_EINVAL; + } + inuse = slot->inuse + id; + *inuse = 1; + return APR_SUCCESS; +} + static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, unsigned int id) { char *inuse; @@ -268,7 +290,10 @@ static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, unsigned int id inuse = slot->inuse; - if (id >= slot->num || !inuse[id] ) { + if (id >= slot->num) { + return APR_EINVAL; + } + if (!inuse[id] ) { return APR_NOTFOUND; } inuse[id] = 0; @@ -287,7 +312,8 @@ static const ap_slotmem_provider_t storage = { &slotmem_num_free_slots, &slotmem_slot_size, &slotmem_grab, - &slotmem_release + &slotmem_release, + &slotmem_fgrab }; static int pre_config(apr_pool_t *p, apr_pool_t *plog, |