]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
And complete the API changes...
authorJim Jagielski <jim@apache.org>
Tue, 30 Dec 2008 17:08:24 +0000 (17:08 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 30 Dec 2008 17:08:24 +0000 (17:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@730181 13f79535-47bb-0310-9956-ffa450edef68

modules/mem/mod_slotmem.h
modules/mem/providers/mod_plainmem.c
modules/mem/providers/mod_sharedmem.c

index ee32a93afc15ce4cd89e279a45fc960473e7bf0b..a26a24424934abb938e8c6c6bb1c86f29b1e2f64 100644 (file)
@@ -74,7 +74,7 @@ struct ap_slotmem {
  */
 typedef apr_status_t ap_slotmem_callback_fn_t(void* mem, void *data, apr_pool_t *pool);
 
-struct slotmem_storage_method {
+struct ap_slotmem_storage_method {
 /**
  * call the callback on all worker slots
  * @param s ap_slotmem_t to use.
@@ -83,7 +83,7 @@ struct slotmem_storage_method {
  * @param pool is pool used to create scoreboard
  * @return APR_SUCCESS if all went well
  */
-AP_DECLARE(apr_status_t) (* slotmem)(ap_slotmem_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool);
+apr_status_t (* slotmem_do)(ap_slotmem_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool);
 
 /**
  * create a new slotmem with each item size is item_size.
@@ -95,7 +95,7 @@ AP_DECLARE(apr_status_t) (* slotmem)(ap_slotmem_t *s, ap_slotmem_callback_fn_t *
  * @param pool is pool used to create scoreboard
  * @return APR_SUCCESS if all went well
  */
-AP_DECLARE(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);
+apr_status_t (* slotmem_create)(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool);
 
 /**
  * attach to an existing slotmem.
@@ -107,7 +107,7 @@ AP_DECLARE(apr_status_t) (* ap_slotmem_create)(ap_slotmem_t **new, const char *n
  * @param pool is pool to memory allocate.
  * @return APR_SUCCESS if all went well
  */
-AP_DECLARE(apr_status_t) (* ap_slotmem_attach)(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool);
+apr_status_t (* slotmem_attach)(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool);
 /**
  * get the memory associated with this worker slot.
  * @param s ap_slotmem_t to use.
@@ -115,23 +115,94 @@ AP_DECLARE(apr_status_t) (* ap_slotmem_attach)(ap_slotmem_t **new, const char *n
  * @param mem address to store the pointer to the slot
  * @return APR_SUCCESS if all went well
  */
-AP_DECLARE(apr_status_t) (* ap_slotmem_mem)(ap_slotmem_t *s, int item_id, void**mem);
+apr_status_t (* slotmem_mem)(ap_slotmem_t *s, int item_id, void**mem);
 /**
  * lock the memory segment
  * NOTE: All slots share the same mutex
  * @param s ap_slotmem_t to use
  * @return APR_SUCCESS if all went well
  */
-AP_DECLARE(apr_status_t) (* ap_slotmem_lock)(ap_slotmem_t *s);
+apr_status_t (* slotmem_lock)(ap_slotmem_t *s);
 /**
  * unlock the memory segment
  * NOTE: All slots share the same mutex
  * @param s ap_slotmem_t to use.
  * @return APR_SUCCESS if all went well
  */
-AP_DECLARE(apr_status_t) (* ap_slotmem_unlock)(ap_slotmem_t *s);
+apr_status_t (* slotmem_unlock)(ap_slotmem_t *s);
 };
 
-typedef struct slotmem_storage_method slotmem_storage_method;
+typedef struct ap_slotmem_storage_method ap_slotmem_storage_method;
+
+/*
+ * mod_slotmem externals exposed to the outside world.
+ *  Thus the provider nature of mod_slotmem is somewhat insulated
+ *  from the end user but can still be used directed if need
+ *  be. The rationale is to make it easier for additional
+ *  memory providers to be provided and having a single
+ *  simple interface for all
+ */
+/**
+ * obtain the provider method desired
+ * @param provider is name of the provider to use
+ * @return pointer to provider or NULL
+ */
+AP_DECLARE(ap_slotmem_storage_method *) ap_slotmem_method(const char *provider);
+/**
+ * call the callback on all worker slots
+ * @param sm ap_slotmem_storage_method provider obtained
+ * @param s ap_slotmem_t to use.
+ * @param funct callback function to call for each element.
+ * @param data parameter for the callback function.
+ * @param pool is pool used to create scoreboard
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) ap_slotmem_do(ap_slotmem_storage_method *sm, ap_slotmem_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool);
+
+/**
+ * create a new slotmem with each item size is item_size.
+ * This would create shared memory, basically.
+ * @param pointer to store the address of the scoreboard.
+ * @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 pool is pool used to create scoreboard
+ * @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, int item_num, apr_pool_t *pool);
+
+/**
+ * attach to an existing slotmem.
+ * This would attach to  shared memory, basically.
+ * @param pointer to store the address of the scoreboard.
+ * @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 max number of item.
+ * @param pool is pool to memory allocate.
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) ap_slotmem_attach(ap_slotmem_storage_method *sm, ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool);
+/**
+ * get the memory associated with this worker slot.
+ * @param s ap_slotmem_t to use.
+ * @param item_id item to return for 0 to item_num
+ * @param mem address to store the pointer to the slot
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) ap_slotmem_mem(ap_slotmem_storage_method *sm, ap_slotmem_t *s, int item_id, void**mem);
+/**
+ * lock the memory segment
+ * NOTE: All slots share the same mutex
+ * @param s ap_slotmem_t to use
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) ap_slotmem_lock(ap_slotmem_storage_method *sm, ap_slotmem_t *s);
+/**
+ * unlock the memory segment
+ * NOTE: All slots share the same mutex
+ * @param s ap_slotmem_t to use.
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) ap_slotmem_unlock(ap_slotmem_storage_method *sm, ap_slotmem_t *s);
 
 #endif /*SLOTMEM_H*/
index 91616f202c6fb6941c3be176d939badc6e69cefd..4adc063256a90394b195d7d1d4e96aa97ed5f25d 100644 (file)
  * This one uses plain memory.
  */
 
-#include  "slotmem.h"
-
-struct ap_slotmem {
-    char *name;
-    void *base;
-    apr_size_t size;
-    int num;
-    struct ap_slotmem *next;
-};
+#include  "mod_slotmem.h"
 
 /* global pool and list of slotmem we are handling */
 static struct ap_slotmem *globallistmem = NULL;
@@ -167,6 +159,7 @@ static int pre_config(apr_pool_t *p, apr_pool_t *plog,
 
 static void ap_plainmem_register_hook(apr_pool_t *p)
 {
+    static const char * const prePos[] = { "mod_slotmem.c", NULL };
     ap_register_provider(p, SLOTMEM_STORAGE, "plain", "0", &storage);
     ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_MIDDLE);
 }
index 0dcecf80267229bb99ed4054d71a3d1b3cf31dea..ff66dc89ace66f4d36033afb35cc96471497fe5c 100644 (file)
@@ -18,7 +18,7 @@
  * This one uses shared memory.
  */
 
-#include  "slotmem.h"
+#include  "mod_slotmem.h"
 
 /* The description of the slots to reuse the slotmem */
 struct sharedslotdesc {
@@ -123,7 +123,7 @@ static apr_status_t cleanup_slotmem(void *param)
     return APR_SUCCESS;
 }
 
-static apr_status_t ap_slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)
+static apr_status_t slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)
 {
     int i;
     void *ptr;
@@ -139,7 +139,7 @@ static apr_status_t ap_slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *f
     }
     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)
+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; */
     void *ptr;
@@ -240,7 +240,7 @@ static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_
     *new = res;
     return APR_SUCCESS;
 }
-static apr_status_t ap_slotmem_attach(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool)
+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; */
     void *ptr;
@@ -313,7 +313,7 @@ static apr_status_t ap_slotmem_attach(ap_slotmem_t **new, const char *name, apr_
     *item_num = desc.item_num;
     return APR_SUCCESS;
 }
-static apr_status_t ap_slotmem_mem(ap_slotmem_t *slot, int id, void **mem)
+static apr_status_t slotmem_mem(ap_slotmem_t *slot, int id, void **mem)
 {
 
     void *ptr;
@@ -333,27 +333,27 @@ static apr_status_t ap_slotmem_mem(ap_slotmem_t *slot, int id, void **mem)
     return APR_SUCCESS;
 }
 
-static apr_status_t ap_slotmem_lock(ap_slotmem_t *slot)
+static apr_status_t slotmem_lock(ap_slotmem_t *slot)
 {
     return (apr_global_mutex_lock(slot->smutex));    
 }
 
-static apr_status_t ap_slotmem_unlock(ap_slotmem_t *slot)
+static apr_status_t slotmem_unlock(ap_slotmem_t *slot)
 {
     return (apr_global_mutex_unlock(slot->smutex));
 }
 
-static const slotmem_storage_method storage = {
-    &ap_slotmem_do,
-    &ap_slotmem_create,
-    &ap_slotmem_attach,
-    &ap_slotmem_mem,
-    &ap_slotmem_lock,
-    &ap_slotmem_unlock
+static const ap_slotmem_storage_method storage = {
+    &slotmem_do,
+    &slotmem_create,
+    &slotmem_attach,
+    &slotmem_mem,
+    &slotmem_lock,
+    &slotmem_unlock
 };
 
 /* make the storage usuable from outside */
-static const slotmem_storage_method *sharedmem_getstorage(void)
+static const ap_slotmem_storage_method *sharedmem_getstorage(void)
 {
     return (&storage);
 }
@@ -466,7 +466,7 @@ static void child_init(apr_pool_t *p, server_rec *s)
 
 static void ap_sharedmem_register_hook(apr_pool_t *p)
 {
-    const slotmem_storage_method *storage = sharedmem_getstorage();
+    const ap_slotmem_storage_method *storage = sharedmem_getstorage();
     ap_register_provider(p, SLOTMEM_STORAGE, "shared", "0", storage);
     ap_hook_post_config(post_config, NULL, NULL, APR_HOOK_LAST);
     ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_MIDDLE);