summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorChris Darroch <chrisd@apache.org>2008-12-30 23:23:35 +0100
committerChris Darroch <chrisd@apache.org>2008-12-30 23:23:35 +0100
commit268060da4b2d294d35367519e69c973a37339d75 (patch)
tree3162ec86aa949089ac06304d3e40aa35c179480b /modules
parentno need here :) (diff)
downloadapache2-268060da4b2d294d35367519e69c973a37339d75.tar.xz
apache2-268060da4b2d294d35367519e69c973a37339d75.zip
detabify and clean some whitespace
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@730262 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r--modules/mem/mod_slotmem.c11
-rw-r--r--modules/mem/mod_slotmem.h2
-rw-r--r--modules/mem/providers/mod_plainmem.c106
-rw-r--r--modules/mem/providers/mod_sharedmem.c259
4 files changed, 193 insertions, 185 deletions
diff --git a/modules/mem/mod_slotmem.c b/modules/mem/mod_slotmem.c
index ea39ebea60..2a3ce57b2d 100644
--- a/modules/mem/mod_slotmem.c
+++ b/modules/mem/mod_slotmem.c
@@ -70,10 +70,11 @@ AP_DECLARE(apr_status_t) ap_slotmem_unlock(ap_slotmem_storage_method *sm,
module AP_MODULE_DECLARE_DATA slotmem_module = {
STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- NULL, /* command apr_table_t */
+ NULL, /* create per-directory config structure */
+ NULL, /* merge per-directory config structures */
+ NULL, /* create per-server config structure */
+ NULL, /* merge per-server config structures */
+ NULL, /* command apr_table_t */
NULL /* register hooks */
};
+
diff --git a/modules/mem/mod_slotmem.h b/modules/mem/mod_slotmem.h
index a26a244249..a9a4a356ef 100644
--- a/modules/mem/mod_slotmem.h
+++ b/modules/mem/mod_slotmem.h
@@ -50,7 +50,7 @@
#define SLOTMEM_STORAGE "slotmem"
-typedef struct ap_slotmem ap_slotmem_t;
+typedef struct ap_slotmem ap_slotmem_t;
struct ap_slotmem {
char *name; /* per segment name */
diff --git a/modules/mem/providers/mod_plainmem.c b/modules/mem/providers/mod_plainmem.c
index 4adc063256..82f8d01cec 100644
--- a/modules/mem/providers/mod_plainmem.c
+++ b/modules/mem/providers/mod_plainmem.c
@@ -30,15 +30,16 @@ static apr_status_t ap_slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *f
void *ptr;
if (!mem)
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
ptr = mem->base;
for (i = 0; i < mem->num; i++) {
- ptr = ptr + mem->size;
- func((void *) ptr, data, pool);
+ ptr = ptr + mem->size;
+ func((void *) ptr, data, pool);
}
return APR_SUCCESS;
}
+
static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool)
{
void *slotmem = NULL;
@@ -48,33 +49,33 @@ static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_
apr_status_t rv;
if (name) {
- if (name[0] == ':')
- fname = name;
- else
- fname = ap_server_root_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;
- }
- }
+ if (name[0] == ':')
+ fname = name;
+ else
+ fname = ap_server_root_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";
+ fname = "anonymous";
/* create the memory using the gpool */
res = (ap_slotmem_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_t));
res->base = apr_pcalloc(gpool, item_size * item_num);
if (!res->base)
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
/* For the chained slotmem stuff */
res->name = apr_pstrdup(gpool, fname);
@@ -82,9 +83,9 @@ static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_
res->num = item_num;
res->next = NULL;
if (globallistmem == NULL)
- globallistmem = res;
+ globallistmem = res;
else
- next->next = res;
+ next->next = res;
*new = res;
return APR_SUCCESS;
@@ -99,28 +100,28 @@ static apr_status_t ap_slotmem_attach(ap_slotmem_t **new, const char *name, apr_
apr_status_t rv;
if (name) {
- if (name[0] == ':')
- fname = name;
- else
- fname = ap_server_root_relative(pool, name);
+ if (name[0] == ':')
+ fname = name;
+ else
+ fname = ap_server_root_relative(pool, name);
}
else
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
/* first try to attach to existing slotmem */
if (next) {
- for (;;) {
- if (strcmp(next->name, fname) == 0) {
- /* we already have it */
- *new = next;
- *item_size = next->size;
- *item_num = next->num;
- return APR_SUCCESS;
- }
- if (!next->next)
- break;
- next = next->next;
- }
+ for (;;) {
+ if (strcmp(next->name, fname) == 0) {
+ /* we already have it */
+ *new = next;
+ *item_size = next->size;
+ *item_num = next->num;
+ return APR_SUCCESS;
+ }
+ if (!next->next)
+ break;
+ next = next->next;
+ }
}
return APR_ENOSHMAVAIL;
@@ -132,13 +133,13 @@ static apr_status_t ap_slotmem_mem(ap_slotmem_t *score, int id, void **mem)
void *ptr;
if (!score)
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
if (id < 0 || id > score->num)
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
ptr = score->base + score->size * id;
if (!ptr)
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
*mem = ptr;
return APR_SUCCESS;
}
@@ -151,7 +152,7 @@ static const slotmem_storage_method storage = {
};
static int pre_config(apr_pool_t *p, apr_pool_t *plog,
- apr_pool_t *ptemp)
+ apr_pool_t *ptemp)
{
gpool = p;
return OK;
@@ -166,10 +167,11 @@ static void ap_plainmem_register_hook(apr_pool_t *p)
module AP_MODULE_DECLARE_DATA plainmem_module = {
STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- NULL, /* command apr_table_t */
- ap_plainmem_register_hook /* register hooks */
+ NULL, /* create per-directory config structure */
+ NULL, /* merge per-directory config structures */
+ NULL, /* create per-server config structure */
+ NULL, /* merge per-server config structures */
+ NULL, /* command apr_table_t */
+ ap_plainmem_register_hook /* register hooks */
};
+
diff --git a/modules/mem/providers/mod_sharedmem.c b/modules/mem/providers/mod_sharedmem.c
index ff66dc89ac..04bbbb7b05 100644
--- a/modules/mem/providers/mod_sharedmem.c
+++ b/modules/mem/providers/mod_sharedmem.c
@@ -45,18 +45,19 @@ static const char *store_filename(apr_pool_t *pool, const char *slotmemname)
const char *storename;
const char *fname;
if (strcmp(slotmemname, "anonymous") == 0)
- fname = ap_server_root_relative(pool, "logs/anonymous");
+ fname = ap_server_root_relative(pool, "logs/anonymous");
else if (slotmemname[0] == ':') {
- const char *tmpname;
- tmpname = apr_pstrcat(pool, "logs/", &slotmemname[1], NULL);
- fname = ap_server_root_relative(pool, tmpname);
+ const char *tmpname;
+ tmpname = apr_pstrcat(pool, "logs/", &slotmemname[1], NULL);
+ fname = ap_server_root_relative(pool, tmpname);
}
else {
- fname = slotmemname;
+ fname = slotmemname;
}
storename = apr_pstrcat(pool, fname, ".slotmem", NULL);
return storename;
}
+
static void store_slotmem(ap_slotmem_t *slotmem)
{
apr_file_t *fp;
@@ -68,11 +69,11 @@ static void store_slotmem(ap_slotmem_t *slotmem)
rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, slotmem->gpool);
if (APR_STATUS_IS_EEXIST(rv)) {
- apr_file_remove(storename, slotmem->gpool);
- rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, slotmem->gpool);
+ apr_file_remove(storename, slotmem->gpool);
+ rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, slotmem->gpool);
}
if (rv != APR_SUCCESS) {
- return;
+ return;
}
nbytes = slotmem->size * slotmem->num;
apr_file_write(fp, slotmem->base, &nbytes);
@@ -89,18 +90,18 @@ static void restore_slotmem(void *ptr, const char *name, apr_size_t item_size, i
storename = store_filename(pool, name);
rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT, pool);
if (rv == APR_SUCCESS) {
- apr_finfo_t fi;
- if (apr_file_info_get(&fi, APR_FINFO_SIZE, fp) == APR_SUCCESS) {
- if (fi.size == nbytes) {
- apr_file_read(fp, ptr, &nbytes);
- }
- else {
- apr_file_close(fp);
- apr_file_remove(storename, pool);
- return;
- }
- }
- apr_file_close(fp);
+ apr_finfo_t fi;
+ if (apr_file_info_get(&fi, APR_FINFO_SIZE, fp) == APR_SUCCESS) {
+ if (fi.size == nbytes) {
+ apr_file_read(fp, ptr, &nbytes);
+ }
+ else {
+ apr_file_close(fp);
+ apr_file_remove(storename, pool);
+ return;
+ }
+ }
+ apr_file_close(fp);
}
}
@@ -111,14 +112,14 @@ static apr_status_t cleanup_slotmem(void *param)
apr_pool_t *pool = NULL;
if (*mem) {
- ap_slotmem_t *next = *mem;
- pool = next->gpool;
- while (next) {
- store_slotmem(next);
- rv = apr_shm_destroy((apr_shm_t *)next->shm);
- next = next->next;
- }
- apr_pool_destroy(pool);
+ ap_slotmem_t *next = *mem;
+ pool = next->gpool;
+ while (next) {
+ store_slotmem(next);
+ rv = apr_shm_destroy((apr_shm_t *)next->shm);
+ next = next->next;
+ }
+ apr_pool_destroy(pool);
}
return APR_SUCCESS;
}
@@ -129,16 +130,17 @@ static apr_status_t slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *func
void *ptr;
if (!mem) {
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
}
ptr = mem->base;
for (i = 0; i < mem->num; i++) {
- ptr = ptr + mem->size;
- func((void *) ptr, data, pool);
+ ptr = ptr + mem->size;
+ func((void *) ptr, data, pool);
}
return APR_SUCCESS;
}
+
static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool)
{
/* void *slotmem = NULL; */
@@ -150,76 +152,76 @@ static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_siz
apr_status_t rv;
if (gpool == NULL)
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
if (name) {
- if (name[0] == ':') {
- fname = name;
- }
- else {
- fname = ap_server_root_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;
- }
- }
+ if (name[0] == ':') {
+ fname = name;
+ }
+ else {
+ fname = ap_server_root_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";
+ fname = "anonymous";
}
/* first try to attach to existing shared memory */
res = (ap_slotmem_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_t));
if (name && name[0] != ':') {
- rv = apr_shm_attach((apr_shm_t **)&res->shm, fname, gpool);
+ rv = apr_shm_attach((apr_shm_t **)&res->shm, fname, gpool);
}
else {
- rv = APR_EINVAL;
+ rv = APR_EINVAL;
}
if (rv == APR_SUCCESS) {
- /* check size */
- if (apr_shm_size_get((apr_shm_t *)res->shm) != item_size * item_num + sizeof(struct sharedslotdesc)) {
- apr_shm_detach((apr_shm_t *)res->shm);
- res->shm = NULL;
- return APR_EINVAL;
- }
- ptr = apr_shm_baseaddr_get((apr_shm_t *)res->shm);
- memcpy(&desc, ptr, sizeof(desc));
- if (desc.item_size != item_size || desc.item_num != item_num) {
- apr_shm_detach((apr_shm_t *)res->shm);
- res->shm = NULL;
- return APR_EINVAL;
- }
- ptr = ptr + sizeof(desc);
+ /* check size */
+ if (apr_shm_size_get((apr_shm_t *)res->shm) != item_size * item_num + sizeof(struct sharedslotdesc)) {
+ apr_shm_detach((apr_shm_t *)res->shm);
+ res->shm = NULL;
+ return APR_EINVAL;
+ }
+ ptr = apr_shm_baseaddr_get((apr_shm_t *)res->shm);
+ memcpy(&desc, ptr, sizeof(desc));
+ if (desc.item_size != item_size || desc.item_num != item_num) {
+ apr_shm_detach((apr_shm_t *)res->shm);
+ res->shm = NULL;
+ return APR_EINVAL;
+ }
+ ptr = ptr + sizeof(desc);
}
else {
- if (name && name[0] != ':') {
- apr_shm_remove(fname, gpool);
- rv = apr_shm_create((apr_shm_t **)&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, gpool);
- }
- else {
- rv = apr_shm_create((apr_shm_t **)&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), NULL, gpool);
- }
- if (rv != APR_SUCCESS) {
- return rv;
- }
- ptr = apr_shm_baseaddr_get((apr_shm_t *)res->shm);
- desc.item_size = item_size;
- desc.item_num = item_num;
- 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 (name && name[0] != ':') {
+ apr_shm_remove(fname, gpool);
+ rv = apr_shm_create((apr_shm_t **)&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, gpool);
+ }
+ else {
+ rv = apr_shm_create((apr_shm_t **)&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), NULL, gpool);
+ }
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ ptr = apr_shm_baseaddr_get((apr_shm_t *)res->shm);
+ desc.item_size = item_size;
+ desc.item_num = item_num;
+ 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);
}
/* For the chained slotmem stuff */
@@ -231,15 +233,16 @@ static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_siz
res->smutex = smutex;
res->next = NULL;
if (globallistmem == NULL) {
- globallistmem = res;
+ globallistmem = res;
}
else {
- next->next = res;
+ next->next = res;
}
*new = res;
return APR_SUCCESS;
}
+
static apr_status_t slotmem_attach(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool)
{
/* void *slotmem = NULL; */
@@ -251,41 +254,41 @@ static apr_status_t slotmem_attach(ap_slotmem_t **new, const char *name, apr_siz
apr_status_t rv;
if (gpool == NULL) {
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
}
if (name) {
- if (name[0] == ':') {
- fname = name;
- }
- else {
- fname = ap_server_root_relative(pool, name);
- }
+ if (name[0] == ':') {
+ fname = name;
+ }
+ else {
+ fname = ap_server_root_relative(pool, name);
+ }
}
else {
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
}
/* first try to attach to existing slotmem */
if (next) {
- for (;;) {
- if (strcmp(next->name, fname) == 0) {
- /* we already have it */
- *new = next;
- *item_size = next->size;
- *item_num = next->num;
- return APR_SUCCESS;
- }
- if (!next->next)
- break;
- next = next->next;
- }
+ for (;;) {
+ if (strcmp(next->name, fname) == 0) {
+ /* we already have it */
+ *new = next;
+ *item_size = next->size;
+ *item_num = next->num;
+ return APR_SUCCESS;
+ }
+ if (!next->next)
+ break;
+ next = next->next;
+ }
}
/* first try to attach to existing shared memory */
res = (ap_slotmem_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_t));
rv = apr_shm_attach((apr_shm_t **)&res->shm, fname, gpool);
if (rv != APR_SUCCESS) {
- return rv;
+ return rv;
}
/* Read the description of the slotmem */
@@ -302,10 +305,10 @@ static apr_status_t slotmem_attach(ap_slotmem_t **new, const char *name, apr_siz
res->smutex = smutex;
res->next = NULL;
if (globallistmem == NULL) {
- globallistmem = res;
+ globallistmem = res;
}
else {
- next->next = res;
+ next->next = res;
}
*new = res;
@@ -313,21 +316,22 @@ static apr_status_t slotmem_attach(ap_slotmem_t **new, const char *name, apr_siz
*item_num = desc.item_num;
return APR_SUCCESS;
}
+
static apr_status_t slotmem_mem(ap_slotmem_t *slot, int id, void **mem)
{
void *ptr;
if (!slot) {
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
}
if (id < 0 || id > slot->num) {
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
}
ptr = slot->base + slot->size * id;
if (!ptr) {
- return APR_ENOSHMAVAIL;
+ return APR_ENOSHMAVAIL;
}
*mem = ptr;
return APR_SUCCESS;
@@ -335,7 +339,7 @@ static apr_status_t slotmem_mem(ap_slotmem_t *slot, int id, void **mem)
static apr_status_t slotmem_lock(ap_slotmem_t *slot)
{
- return (apr_global_mutex_lock(slot->smutex));
+ return (apr_global_mutex_lock(slot->smutex));
}
static apr_status_t slotmem_unlock(ap_slotmem_t *slot)
@@ -370,7 +374,7 @@ static void sharedmem_initialize_cleanup(apr_pool_t *p)
apr_pool_cleanup_register(p, &globallistmem, cleanup_slotmem, apr_pool_cleanup_null);
}
-/*
+/*
* Create the shared mem mutex and
* make sure the shared memory is cleaned
*/
@@ -435,16 +439,16 @@ static int post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, serve
}
static int pre_config(apr_pool_t *p, apr_pool_t *plog,
- apr_pool_t *ptemp)
+ apr_pool_t *ptemp)
{
apr_pool_t *global_pool;
apr_status_t rv;
rv = apr_pool_create(&global_pool, NULL);
if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
- "Fatal error: unable to create global pool for shared slotmem");
- return rv;
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
+ "Fatal error: unable to create global pool for shared slotmem");
+ return rv;
}
sharedmem_initgpool(global_pool);
return OK;
@@ -475,10 +479,11 @@ static void ap_sharedmem_register_hook(apr_pool_t *p)
module AP_MODULE_DECLARE_DATA sharedmem_module = {
STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- NULL, /* command apr_table_t */
- ap_sharedmem_register_hook /* register hooks */
+ NULL, /* create per-directory config structure */
+ NULL, /* merge per-directory config structures */
+ NULL, /* create per-server config structure */
+ NULL, /* merge per-server config structures */
+ NULL, /* command apr_table_t */
+ ap_sharedmem_register_hook /* register hooks */
};
+