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/09/18 12:59:21 UTC
svn commit: r1387088 - in /httpd/httpd/trunk:
docs/manual/mod/mod_slotmem_shm.xml include/ap_slotmem.h
modules/slotmem/mod_slotmem_shm.c
Author: jim
Date: Tue Sep 18 10:59:20 2012
New Revision: 1387088
URL: http://svn.apache.org/viewvc?rev=1387088&view=rev
Log:
Add in new type CLEARINUSE which allows the inuse table to
be cleared upon storage. This may be expected/wanted/required
by some applications
Modified:
httpd/httpd/trunk/docs/manual/mod/mod_slotmem_shm.xml
httpd/httpd/trunk/include/ap_slotmem.h
httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c
Modified: httpd/httpd/trunk/docs/manual/mod/mod_slotmem_shm.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_slotmem_shm.xml?rev=1387088&r1=1387087&r2=1387088&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_slotmem_shm.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_slotmem_shm.xml Tue Sep 18 10:59:20 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/trunk/include/ap_slotmem.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_slotmem.h?rev=1387088&r1=1387087&r2=1387088&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_slotmem.h (original)
+++ httpd/httpd/trunk/include/ap_slotmem.h Tue Sep 18 10:59:20 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/trunk/modules/slotmem/mod_slotmem_shm.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c?rev=1387088&r1=1387087&r2=1387088&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c (original)
+++ httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c Tue Sep 18 10:59:20 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 {
@@ -152,6 +153,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;
@@ -175,6 +195,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;
/* XXX: Error handling */