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
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@
1394021 13f79535-47bb-0310-9956-
ffa450edef68
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 ]
<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>
* 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;
#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 {
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;
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);