From 3111b393e40189fa20f659bab6f45a7df4d0cbd1 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 5 May 2009 12:38:15 +0000 Subject: [PATCH] Move to an enum, instead of bitmaps... no functional change git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@771697 13f79535-47bb-0310-9956-ffa450edef68 --- include/ap_slotmem.h | 8 +++++--- modules/mem/mod_plainmem.c | 2 +- modules/mem/mod_sharedmem.c | 7 +++++-- server/slotmem.c | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/ap_slotmem.h b/include/ap_slotmem.h index 9de53fbcb1..cdd2677ee5 100644 --- a/include/ap_slotmem.h +++ b/include/ap_slotmem.h @@ -50,7 +50,9 @@ #define AP_SLOTMEM_STORAGE "slotmem" -#define CREPER_SLOTMEM 2 /* create a persistent slotmem */ +typedef enum { + SLOTMEM_PERSIST /* create a persistent slotmem */ +} apslotmem_type; typedef struct ap_slotmem_t ap_slotmem_t; @@ -87,7 +89,7 @@ struct ap_slotmem_storage_method { * @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, int type, 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, apslotmem_type type, apr_pool_t *pool); /** * attach to an existing slotmem. * This would attach to shared memory, basically. @@ -170,7 +172,7 @@ AP_DECLARE(apr_status_t) ap_slotmem_do(ap_slotmem_storage_method *sm, ap_slotmem * @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, int type, 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, apslotmem_type type, apr_pool_t *pool); /** * attach to an existing slotmem. diff --git a/modules/mem/mod_plainmem.c b/modules/mem/mod_plainmem.c index 29e35992c4..608b75ef71 100644 --- a/modules/mem/mod_plainmem.c +++ b/modules/mem/mod_plainmem.c @@ -51,7 +51,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, int type, 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, apslotmem_type type, apr_pool_t *pool) { ap_slotmem_t *res; ap_slotmem_t *next = globallistmem; diff --git a/modules/mem/mod_sharedmem.c b/modules/mem/mod_sharedmem.c index 8d1dc7469d..f0d7bae88e 100644 --- a/modules/mem/mod_sharedmem.c +++ b/modules/mem/mod_sharedmem.c @@ -63,6 +63,7 @@ static apr_pool_t *gpool = NULL; static apr_global_mutex_t *smutex; static const char *mutex_fname; +/* apr:shmem/unix/shm.c */ static apr_status_t unixd_set_shm_perms(const char *fname) { #ifdef AP_NEED_SET_MUTEX_PERMS @@ -207,7 +208,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, int type, 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, apslotmem_type type, apr_pool_t *pool) { /* void *slotmem = NULL; */ void *ptr; @@ -283,6 +284,8 @@ static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_siz /* Set permissions to shared memory * so it can be attached by child process * having different user credentials + * + * See apr:shmem/unix/shm.c */ unixd_set_shm_perms(fname); } @@ -292,7 +295,7 @@ 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); - if (type & CREPER_SLOTMEM) + if (type == SLOTMEM_PERSIST) restore_slotmem(ptr, fname, item_size, item_num, pool); } diff --git a/server/slotmem.c b/server/slotmem.c index 63576c2825..f3fc561d42 100644 --- a/server/slotmem.c +++ b/server/slotmem.c @@ -42,7 +42,7 @@ 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, + apslotmem_type type, apr_pool_t *pool) { return (sm->slotmem_create(new, name, item_size, item_num, type, pool)); -- 2.50.1