httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r775255 - in /httpd/httpd/trunk: include/ap_slotmem.h modules/slotmem/mod_slotmem_plain.c modules/slotmem/mod_slotmem_shm.c
Date Fri, 15 May 2009 17:41:57 GMT
Author: jim
Date: Fri May 15 17:41:56 2009
New Revision: 775255

URL: http://svn.apache.org/viewvc?rev=775255&view=rev
Log:
Another slotmem flag. This one determines if access
requires grab/return

Modified:
    httpd/httpd/trunk/include/ap_slotmem.h
    httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c
    httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c

Modified: httpd/httpd/trunk/include/ap_slotmem.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_slotmem.h?rev=775255&r1=775254&r2=775255&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_slotmem.h (original)
+++ httpd/httpd/trunk/include/ap_slotmem.h Fri May 15 17:41:56 2009
@@ -57,8 +57,17 @@
 
 typedef unsigned int ap_slotmem_type_t;
 
+/*
+ * AP_SLOTMEM_TYPE_PERSIST: For transitory providers, persist
+ *    the data on the file-system
+ *
+ * AP_SLOTMEM_TYPE_NOTMPSAFE:
+ *
+ * AP_SLOTMEM_TYPE_PREALLOC: Access to slots require they be grabbed 1st
+ */
 #define AP_SLOTMEM_TYPE_PERSIST   (1 << 0)
 #define AP_SLOTMEM_TYPE_NOTMPSAFE (1 << 1)
+#define AP_SLOTMEM_TYPE_PREGRAB   (1 << 2)
 
 typedef struct ap_slotmem_instance_t ap_slotmem_instance_t;
 

Modified: httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c?rev=775255&r1=775254&r2=775255&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c (original)
+++ httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c Fri May 15 17:41:56 2009
@@ -26,6 +26,8 @@
     apr_size_t           size;        /* size of each memory slot */
     unsigned int         num;         /* number of mem slots */
     apr_pool_t           *gpool;      /* per segment global pool */
+    char                 *inuse;      /* in-use flag table*/
+    ap_slotmem_type_t    type;        /* type-specific flags */
     struct ap_slotmem_instance_t  *next;       /* location of next allocated segment */
 };
 
@@ -86,6 +88,7 @@
     res->size = item_size;
     res->num = item_num;
     res->next = NULL;
+    res->type = type;
     if (globallistmem == NULL)
         globallistmem = res;
     else

Modified: httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c?rev=775255&r1=775254&r2=775255&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c (original)
+++ httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c Fri May 15 17:41:56 2009
@@ -39,6 +39,8 @@
 #endif
 #endif
 
+#define AP_SLOTMEM_IS_PREGRAB(t) (t->type & AP_SLOTMEM_TYPE_PREGRAB)
+
 struct ap_slotmem_instance_t {
     char                 *name;       /* per segment name */
     void                 *shm;        /* ptr to memory segment (apr_shm_t *) */
@@ -46,8 +48,9 @@
     apr_size_t           size;        /* size of each memory slot */
     unsigned int         num;         /* number of mem slots */
     apr_pool_t           *gpool;      /* per segment global pool */
-    struct ap_slotmem_instance_t  *next;       /* location of next allocated segment */
     char                 *inuse;      /* in-use flag table*/
+    ap_slotmem_type_t    type;        /* type-specific flags */
+    struct ap_slotmem_instance_t  *next;       /* location of next allocated segment */
 };
 
 
@@ -55,6 +58,7 @@
 struct sharedslotdesc {
     apr_size_t item_size;
     unsigned int item_num;
+    ap_slotmem_type_t type;
 };
 
 /*
@@ -207,7 +211,8 @@
     ptr = mem->base;
     inuse = mem->inuse;
     for (i = 0; i < mem->num; i++, inuse++) {
-        if (*inuse) {
+        if (!AP_SLOTMEM_IS_PREGRAB(mem) ||
+           (AP_SLOTMEM_IS_PREGRAB(mem) && *inuse)) {
             func((void *) ptr, data, pool);
         }
         ptr += mem->size;
@@ -297,6 +302,7 @@
         ptr = apr_shm_baseaddr_get(shm);
         desc.item_size = item_size;
         desc.item_num = item_num;
+        desc.type = type;
         memcpy(ptr, &desc, sizeof(desc));
         ptr = ptr + sizeof(desc);
         memset(ptr, 0, dsize);
@@ -311,6 +317,7 @@
     res->base = ptr;
     res->size = item_size;
     res->num = item_num;
+    res->type = type;
     res->gpool = gpool;
     res->next = NULL;
     res->inuse = ptr + basesize;
@@ -381,6 +388,7 @@
     res->base = ptr;
     res->size = desc.item_size;
     res->num = desc.item_num;
+    res->type = desc.type;
     res->gpool = gpool;
     res->inuse = ptr + (desc.item_size * desc.item_num);
     res->next = NULL;
@@ -399,7 +407,6 @@
 
 static apr_status_t slotmem_mem(ap_slotmem_instance_t *slot, unsigned int id, void **mem)
 {
-
     void *ptr;
 
     if (!slot) {
@@ -419,7 +426,6 @@
 
 static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, unsigned char
*dest, apr_size_t dest_len)
 {
-
     void *ptr;
     char *inuse;
     apr_status_t ret;
@@ -428,8 +434,8 @@
         return APR_ENOSHMAVAIL;
     }
 
-    inuse = slot->inuse;
-    if (id >= slot->num || !inuse[id] ) {
+    inuse = slot->inuse + id;
+    if (id >= slot->num || (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse)) {
         return APR_NOTFOUND;
     }
     ret = slotmem_mem(slot, id, &ptr);
@@ -442,7 +448,6 @@
 
 static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, unsigned char
*src, apr_size_t src_len)
 {
-
     void *ptr;
     char *inuse;
     apr_status_t ret;
@@ -451,8 +456,8 @@
         return APR_ENOSHMAVAIL;
     }
 
-    inuse = slot->inuse;
-    if (id >= slot->num || !inuse[id] ) {
+    inuse = slot->inuse + id;
+    if (id >= slot->num || (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse)) {
         return APR_NOTFOUND;
     }
     ret = slotmem_mem(slot, id, &ptr);
@@ -473,9 +478,12 @@
     return slot->size;
 }
 
+/*
+ * XXXX: if !AP_SLOTMEM_IS_PREGRAB, then still worry about
+ *       inuse for grab and return?
+ */
 static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id)
 {
-
     unsigned int i;
     char *inuse;
 
@@ -500,7 +508,6 @@
 
 static apr_status_t slotmem_return(ap_slotmem_instance_t *slot, unsigned int id)
 {
-
     char *inuse;
 
     if (!slot) {



Mime
View raw message