httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r730181 - in /httpd/httpd/trunk/modules/mem: mod_slotmem.h providers/mod_plainmem.c providers/mod_sharedmem.c
Date Tue, 30 Dec 2008 17:08:24 GMT
Author: jim
Date: Tue Dec 30 09:08:24 2008
New Revision: 730181

URL: http://svn.apache.org/viewvc?rev=730181&view=rev
Log:
And complete the API changes...

Modified:
    httpd/httpd/trunk/modules/mem/mod_slotmem.h
    httpd/httpd/trunk/modules/mem/providers/mod_plainmem.c
    httpd/httpd/trunk/modules/mem/providers/mod_sharedmem.c

Modified: httpd/httpd/trunk/modules/mem/mod_slotmem.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mem/mod_slotmem.h?rev=730181&r1=730180&r2=730181&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mem/mod_slotmem.h (original)
+++ httpd/httpd/trunk/modules/mem/mod_slotmem.h Tue Dec 30 09:08:24 2008
@@ -74,7 +74,7 @@
  */
 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 @@
  * @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 @@
  * @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 @@
  * @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 @@
  * @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*/

Modified: httpd/httpd/trunk/modules/mem/providers/mod_plainmem.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mem/providers/mod_plainmem.c?rev=730181&r1=730180&r2=730181&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mem/providers/mod_plainmem.c (original)
+++ httpd/httpd/trunk/modules/mem/providers/mod_plainmem.c Tue Dec 30 09:08:24 2008
@@ -18,15 +18,7 @@
  * 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 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);
 }

Modified: httpd/httpd/trunk/modules/mem/providers/mod_sharedmem.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mem/providers/mod_sharedmem.c?rev=730181&r1=730180&r2=730181&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mem/providers/mod_sharedmem.c (original)
+++ httpd/httpd/trunk/modules/mem/providers/mod_sharedmem.c Tue Dec 30 09:08:24 2008
@@ -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 @@
     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 @@
     }
     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 @@
     *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 @@
     *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 @@
     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 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);



Mime
View raw message