You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2012/10/04 14:49:10 UTC

svn commit: r1394021 - in /httpd/httpd/branches/2.4.x: ./ STATUS docs/manual/mod/mod_slotmem_shm.xml include/ap_slotmem.h modules/slotmem/mod_slotmem_shm.c

Author: jim
Date: Thu Oct  4 12:49:09 2012
New Revision: 1394021

URL: http://svn.apache.org/viewvc?rev=1394021&view=rev
Log:
Merge r1387088 from trunk:

Add in new type CLEARINUSE which allows the inuse table to
be cleared upon storage. This may be expected/wanted/required
by some applications

Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/docs/manual/mod/mod_slotmem_shm.xml
    httpd/httpd/branches/2.4.x/include/ap_slotmem.h
    httpd/httpd/branches/2.4.x/modules/slotmem/mod_slotmem_shm.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1387088

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1394021&r1=1394020&r2=1394021&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Thu Oct  4 12:49:09 2012
@@ -89,11 +89,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
   
-   * mod_slotmem_shm: New slotmem_shm type CLEARINUSE which clears this
-     table before persisting:
-     trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1387088
-      2.4.x patch: trunk patch works
-     +1: jim, humbedooh, rjung
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]

Modified: httpd/httpd/branches/2.4.x/docs/manual/mod/mod_slotmem_shm.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/mod/mod_slotmem_shm.xml?rev=1394021&r1=1394020&r2=1394021&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/mod/mod_slotmem_shm.xml (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/mod/mod_slotmem_shm.xml Thu Oct  4 12:49:09 2012
@@ -51,11 +51,11 @@
       <dd>call the callback on all worker slots</dd>
 
       <dt>apr_status_t create(ap_slotmem_instance_t **new, const char *name, apr_size_t item_size, unsigned int item_num, ap_slotmem_type_t type, apr_pool_t *pool)</dt>
-      <dd>create a new slotmem with each item size is item_size. <code>name</code> is the filename for the persistent store of
-      the shared memory. Values are:
+      <dd>create a new slotmem with each item size is item_size. <code>name</code> is used to generate a filename for the persistent store of
+      the shared memory if configured. Values are:
        <dl>
          <dt><code>"none"</code></dt>
-         <dd><code>Does not persist shared memory in file.</code></dd>
+         <dd><code>Anonymous shared memory and no persistent store</code></dd>
          <dt><code>"file-name"</code></dt>
          <dd><code>[DefaultRuntimeDir]/file-name</code></dd>
          <dt><code>"/absolute-file-name"</code></dt>

Modified: httpd/httpd/branches/2.4.x/include/ap_slotmem.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_slotmem.h?rev=1394021&r1=1394020&r2=1394021&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_slotmem.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_slotmem.h Thu Oct  4 12:49:09 2012
@@ -62,10 +62,14 @@ typedef unsigned int ap_slotmem_type_t;
  * AP_SLOTMEM_TYPE_NOTMPSAFE:
  *
  * AP_SLOTMEM_TYPE_PREALLOC: Access to slots require they be grabbed 1st
+ *
+ * AP_SLOTMEM_TYPE_CLEARINUSE: If persisting, clear 'inuse' array before
+ *    storing
  */
-#define AP_SLOTMEM_TYPE_PERSIST   (1 << 0)
-#define AP_SLOTMEM_TYPE_NOTMPSAFE (1 << 1)
-#define AP_SLOTMEM_TYPE_PREGRAB   (1 << 2)
+#define AP_SLOTMEM_TYPE_PERSIST      (1 << 0)
+#define AP_SLOTMEM_TYPE_NOTMPSAFE    (1 << 1)
+#define AP_SLOTMEM_TYPE_PREGRAB      (1 << 2)
+#define AP_SLOTMEM_TYPE_CLEARINUSE   (1 << 3)
 
 typedef struct ap_slotmem_instance_t ap_slotmem_instance_t;
 

Modified: httpd/httpd/branches/2.4.x/modules/slotmem/mod_slotmem_shm.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/slotmem/mod_slotmem_shm.c?rev=1394021&r1=1394020&r2=1394021&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/slotmem/mod_slotmem_shm.c (original)
+++ httpd/httpd/branches/2.4.x/modules/slotmem/mod_slotmem_shm.c Thu Oct  4 12:49:09 2012
@@ -43,8 +43,9 @@
 #endif
 #endif
 
-#define AP_SLOTMEM_IS_PREGRAB(t) (t->desc.type & AP_SLOTMEM_TYPE_PREGRAB)
-#define AP_SLOTMEM_IS_PERSIST(t) (t->desc.type & AP_SLOTMEM_TYPE_PERSIST)
+#define AP_SLOTMEM_IS_PREGRAB(t)    (t->desc.type & AP_SLOTMEM_TYPE_PREGRAB)
+#define AP_SLOTMEM_IS_PERSIST(t)    (t->desc.type & AP_SLOTMEM_TYPE_PERSIST)
+#define AP_SLOTMEM_IS_CLEARINUSE(t) (t->desc.type & AP_SLOTMEM_TYPE_CLEARINUSE)
 
 /* The description of the slots to reuse the slotmem */
 typedef struct {
@@ -144,6 +145,25 @@ static const char *slotmem_filename(apr_
     return fname;
 }
 
+static void slotmem_clearinuse(ap_slotmem_instance_t *slot)
+{
+    unsigned int i;
+    char *inuse;
+    
+    if (!slot) {
+        return;
+    }
+    
+    inuse = slot->inuse;
+    
+    for (i = 0; i < slot->desc.num; i++, inuse++) {
+        if (*inuse) {
+            *inuse = 0;
+            (*slot->num_free)++;
+        }
+    }
+}
+
 static void store_slotmem(ap_slotmem_instance_t *slotmem)
 {
     apr_file_t *fp;
@@ -164,6 +184,9 @@ static void store_slotmem(ap_slotmem_ins
         if (rv != APR_SUCCESS) {
             return;
         }
+        if (AP_SLOTMEM_IS_CLEARINUSE(slotmem)) {
+            slotmem_clearinuse(slotmem);
+        }
         nbytes = (slotmem->desc.size * slotmem->desc.num) +
                  (slotmem->desc.num * sizeof(char)) + AP_UNSIGNEDINT_OFFSET;
         apr_file_write(fp, slotmem->persist, &nbytes);