From 107549cad7a98819c4efd7283ec64729e0dc4ab7 Mon Sep 17 00:00:00 2001 From: Jean-Frederic Clere Date: Mon, 4 May 2009 12:22:36 +0000 Subject: [PATCH] Add a parameter for slotmem_create for the persistancy of the slotmem area. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@771286 13f79535-47bb-0310-9956-ffa450edef68 --- include/ap_slotmem.h | 8 ++++++-- modules/mem/mod_sharedmem.c | 5 +++-- server/slotmem.c | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/ap_slotmem.h b/include/ap_slotmem.h index a9578a18e0..9de53fbcb1 100644 --- a/include/ap_slotmem.h +++ b/include/ap_slotmem.h @@ -50,6 +50,8 @@ #define AP_SLOTMEM_STORAGE "slotmem" +#define CREPER_SLOTMEM 2 /* create a persistent slotmem */ + typedef struct ap_slotmem_t ap_slotmem_t; /** @@ -81,10 +83,11 @@ struct ap_slotmem_storage_method { * @param name is a key used for debugging and in mod_status output or allow another process to share this space. * @param item_size size of each item * @param item_num number of item to create. + * @param type type of slotmem. * @param pool is pool used * @return APR_SUCCESS if all went well */ - apr_status_t (* slotmem_create)(ap_slotmem_t **new, const char *name, apr_size_t item_size, unsigned int item_num, apr_pool_t *pool); + apr_status_t (* slotmem_create)(ap_slotmem_t **new, const char *name, apr_size_t item_size, unsigned int item_num, int type, apr_pool_t *pool); /** * attach to an existing slotmem. * This would attach to shared memory, basically. @@ -163,10 +166,11 @@ AP_DECLARE(apr_status_t) ap_slotmem_do(ap_slotmem_storage_method *sm, ap_slotmem * @param name is a key used for debugging and in mod_status output or allow another process to share this space. * @param item_size size of each item * @param item_num number of item to create. + * @param type (persistent/allocatable/etc) * @param pool is pool used * @return APR_SUCCESS if all went well */ -AP_DECLARE(apr_status_t) ap_slotmem_create(ap_slotmem_storage_method *sm, ap_slotmem_t **new, const char *name, apr_size_t item_size, unsigned int item_num, apr_pool_t *pool); +AP_DECLARE(apr_status_t) ap_slotmem_create(ap_slotmem_storage_method *sm, ap_slotmem_t **new, const char *name, apr_size_t item_size, unsigned int item_num, int type, apr_pool_t *pool); /** * attach to an existing slotmem. diff --git a/modules/mem/mod_sharedmem.c b/modules/mem/mod_sharedmem.c index 600617308e..259f466773 100644 --- a/modules/mem/mod_sharedmem.c +++ b/modules/mem/mod_sharedmem.c @@ -207,7 +207,7 @@ static apr_status_t slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *func return APR_SUCCESS; } -static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_size_t item_size, unsigned int item_num, apr_pool_t *pool) +static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_size_t item_size, unsigned int item_num, int type, apr_pool_t *pool) { /* void *slotmem = NULL; */ void *ptr; @@ -292,7 +292,8 @@ static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_siz memcpy(ptr, &desc, sizeof(desc)); ptr = ptr + sizeof(desc); memset(ptr, 0, item_size * item_num); - restore_slotmem(ptr, fname, item_size, item_num, pool); + if (type & CREPER_SLOTMEM) + restore_slotmem(ptr, fname, item_size, item_num, pool); } /* For the chained slotmem stuff */ diff --git a/server/slotmem.c b/server/slotmem.c index 8d4e31fd86..63576c2825 100644 --- a/server/slotmem.c +++ b/server/slotmem.c @@ -42,9 +42,10 @@ AP_DECLARE(apr_status_t) ap_slotmem_do(ap_slotmem_storage_method *sm, AP_DECLARE(apr_status_t) ap_slotmem_create(ap_slotmem_storage_method *sm, ap_slotmem_t **new, const char *name, apr_size_t item_size, unsigned int item_num, + int type, apr_pool_t *pool) { - return (sm->slotmem_create(new, name, item_size, item_num, pool)); + return (sm->slotmem_create(new, name, item_size, item_num, type, pool)); } AP_DECLARE(apr_status_t) ap_slotmem_attach(ap_slotmem_storage_method *sm, -- 2.40.0