]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Allow for a forced grab of a slotmem slot.
authorJim Jagielski <jim@apache.org>
Mon, 17 Sep 2012 22:26:28 +0000 (22:26 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 17 Sep 2012 22:26:28 +0000 (22:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1386880 13f79535-47bb-0310-9956-ffa450edef68

docs/log-message-tags/next-number
docs/manual/mod/mod_slotmem_plain.xml
docs/manual/mod/mod_slotmem_shm.xml
include/ap_slotmem.h
modules/slotmem/mod_slotmem_plain.c
modules/slotmem/mod_slotmem_shm.c

index d61563f9298b02831ad6a0c5e843b354856d8027..fd75012648ec57862e0c7980f0ed4f3ca1214f6c 100644 (file)
@@ -1 +1 @@
-2336
+2337
index d5f9d232c451d24a35101cace2f27e70669aac2e..61603f189f5b8197754148f4fba5bae6f628fd5f 100644 (file)
       <dt>apr_size_t slot_size(ap_slotmem_instance_t *s)</dt>
       <dd>return the total data size, in bytes, of a slot in the segment</dd>
 
-      <dt>apr_status_t grab(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
+      <dt>apr_status_t grab(ap_slotmem_instance_t *s, unsigned int *item_id);</dt>
       <dd>grab or allocate a slot and mark as in-use (does not do any data copying)</dd>
 
-      <dt>apr_status_t release(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
+      <dt>apr_status_t fgrab(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
+      <dd>forced grab or allocate a slot and mark as in-use (does not do any data copying)</dd>
+        
+     <dt>apr_status_t release(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
       <dd>release or free a slot and mark as not in-use (does not do any data copying)</dd>
     </dl>
 
index cee9a8e4ebf90437d97243d19b525a19a2f659c2..e129970f167ea738f80a0983317635c82b9c2f6a 100644 (file)
       <dt>apr_size_t slot_size(ap_slotmem_instance_t *s)</dt>
       <dd>return the total data size, in bytes, of a slot in the segment</dd>
 
-      <dt>apr_status_t grab(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
+      <dt>apr_status_t grab(ap_slotmem_instance_t *s, unsigned int *item_id);</dt>
       <dd>grab or allocate a slot and mark as in-use (does not do any data copying)</dd>
 
+      <dt>apr_status_t grab(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
+      <dd>forced grab or allocate a slot and mark as in-use (does not do any data copying)</dd>
+
       <dt>apr_status_t release(ap_slotmem_instance_t *s, unsigned int item_id);</dt>
       <dd>release or free a slot and mark as not in-use (does not do any data copying)</dd>
     </dl>
index 496f455e69bcc17cf58247583e3968d2b6bd1ef8..229aa713f43c1208c83950b47c4f94187e71ebea 100644 (file)
@@ -175,6 +175,13 @@ struct ap_slotmem_provider_t {
      * @return APR_SUCCESS if all went well
      */
     apr_status_t (* release)(ap_slotmem_instance_t *s, unsigned int item_id);
+    /**
+     * forced grab (or alloc) a slot associated with this item_id
+     * @param s ap_slotmem_instance_t to use.
+     * @param item_id to the specified slot id and marked as in-use
+     * @return APR_SUCCESS if all went well
+     */
+    apr_status_t (* fgrab)(ap_slotmem_instance_t *s, unsigned int item_id);
 };
 
 typedef struct ap_slotmem_provider_t ap_slotmem_provider_t;
index dc62f46f85b83d68d572672bf383152f5bb55efb..cc33bfd654cf64d152ef2b2416a91e0f0bd97af5 100644 (file)
@@ -154,7 +154,7 @@ static apr_status_t slotmem_dptr(ap_slotmem_instance_t *score, unsigned int id,
     if (!score)
         return APR_ENOSHMAVAIL;
     if (id >= score->num)
-        return APR_ENOSHMAVAIL;
+        return APR_EINVAL;
 
     ptr = (char *)score->base + score->size * id;
     if (!ptr)
@@ -174,7 +174,10 @@ static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, un
     }
 
     inuse = slot->inuse + id;
-    if (id >= slot->num || (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse)) {
+    if (id >= slot->num) {
+        return APR_EINVAL;
+    }
+    if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) {
         return APR_NOTFOUND;
     }
     ret = slotmem_dptr(slot, id, &ptr);
@@ -197,7 +200,10 @@ static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, un
     }
 
     inuse = slot->inuse + id;
-    if (id >= slot->num || (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse)) {
+    if (id >= slot->num) {
+        return APR_EINVAL;
+    }
+    if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) {
         return APR_NOTFOUND;
     }
     ret = slotmem_dptr(slot, id, &ptr);
@@ -251,13 +257,31 @@ static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id)
         }
     }
     if (i >= slot->num) {
-        return APR_ENOSHMAVAIL;
+        return APR_EINVAL;
     }
     *inuse = 1;
     *id = i;
     return APR_SUCCESS;
 }
 
+*/
+static apr_status_t slotmem_fgrab(ap_slotmem_instance_t *slot, unsigned int id)
+{
+    unsigned int i;
+    char *inuse;
+    
+    if (!slot) {
+        return APR_ENOSHMAVAIL;
+    }
+    
+    if (id >= slot->num) {
+        return APR_EINVAL;
+    }
+    inuse = slot->inuse + id;
+    *inuse = 1;
+    return APR_SUCCESS;
+}
+
 static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, unsigned int id)
 {
     char *inuse;
@@ -268,7 +292,10 @@ static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, unsigned int id
 
     inuse = slot->inuse;
 
-    if (id >= slot->num || !inuse[id] ) {
+    if (id >= slot->num) {
+        return APR_EINVAL;
+    }
+    if (!inuse[id] ) {
         return APR_NOTFOUND;
     }
     inuse[id] = 0;
@@ -287,7 +314,8 @@ static const ap_slotmem_provider_t storage = {
     &slotmem_num_free_slots,
     &slotmem_slot_size,
     &slotmem_grab,
-    &slotmem_release
+    &slotmem_release,
+    &slotmem_fgrab
 };
 
 static int pre_config(apr_pool_t *p, apr_pool_t *plog,
index bdc46ad80e0ec9c9c36ed16eb60543a48fbe054f..651f6336027f4a48655eada1507e1c9465778326 100644 (file)
@@ -608,6 +608,30 @@ static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id)
     return APR_SUCCESS;
 }
 
+static apr_status_t slotmem_fgrab(ap_slotmem_instance_t *slot, unsigned int id)
+{
+    char *inuse;
+    
+    if (!slot) {
+        return APR_ENOSHMAVAIL;
+    }
+
+    if (id >= slot->desc.num) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02236)
+                     "slotmem(%s) fgrab failed. Num %u/num_free %u",
+                     slot->name, slotmem_num_slots(slot),
+                     slotmem_num_free_slots(slot));
+        return APR_EINVAL;
+    }
+    inuse = slot->inuse + id;
+
+    if (!*inuse) {
+        *inuse = 1;
+        (*slot->num_free)--;
+    }
+    return APR_SUCCESS;
+}
+
 static apr_status_t slotmem_release(ap_slotmem_instance_t *slot,
                                     unsigned int id)
 {
@@ -647,7 +671,8 @@ static const ap_slotmem_provider_t storage = {
     &slotmem_num_free_slots,
     &slotmem_slot_size,
     &slotmem_grab,
-    &slotmem_release
+    &slotmem_release,
+    &slotmem_fgrab
 };
 
 /* make the storage usuable from outside */