httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1001831 - in /httpd/httpd/trunk: docs/manual/mod/mod_slotmem_shm.xml modules/slotmem/mod_slotmem_shm.c
Date Mon, 27 Sep 2010 17:37:34 GMT
Author: jim
Date: Mon Sep 27 17:37:33 2010
New Revision: 1001831

URL: http://svn.apache.org/viewvc?rev=1001831&view=rev
Log:
Allow for non-persist of shared mem

Modified:
    httpd/httpd/trunk/docs/manual/mod/mod_slotmem_shm.xml
    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=1001831&r1=1001830&r2=1001831&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_slotmem_shm.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_slotmem_shm.xml Mon Sep 27 17:37:33 2010
@@ -49,13 +49,15 @@
       <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 persistant store of
+      <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:
        <dl>
-         <dt><code>anonymous</code></dt>
+         <dt><code>"none"</code></dt>
+         <dd><code>Does not persist shared memory in file.</code></dd>
+         <dt><code>"anonymous"</code></dt>
          <dd><code>$server_root/logs/anonymous.slotmem</code></dd>
-         <dt><code>:module_name.c</code></dt>
-         <dd><code>$server_root/logs/module_name.c.slotmem</code></dd>
+         <dt><code>":file-name"</code></dt>
+         <dd><code>$server_root/logs/file-name.slotmem</code></dd>
          <dt><code>"absolute-file-name"</code></dt>
          <dd><code>$absolute-file-name.slotmem</code></dd>
        </dl>

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=1001831&r1=1001830&r2=1001831&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c (original)
+++ httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c Mon Sep 27 17:37:33 2010
@@ -106,10 +106,11 @@ static apr_status_t unixd_set_shm_perms(
 }
 
 /*
- * Persiste the slotmem in a file
+ * Persist the slotmem in a file
  * slotmem name and file name.
+ * none      : no persistent data
  * anonymous : $server_root/logs/anonymous.slotmem
- * :module.c : $server_root/logs/module.c.slotmem
+ * :rel_name : $server_root/logs/rel_name.slotmem
  * abs_name  : $abs_name.slotmem
  *
  */
@@ -117,7 +118,9 @@ static const char *store_filename(apr_po
 {
     const char *storename;
     const char *fname;
-    if (strcmp(slotmemname, "anonymous") == 0)
+    if (strcasecmp(slotmemname, "none") == 0)
+        return NULL;
+    else if (strcasecmp(slotmemname, "anonymous") == 0)
         fname = ap_server_root_relative(pool, "logs/anonymous");
     else if (slotmemname[0] == ':') {
         const char *tmpname;
@@ -140,20 +143,22 @@ static void store_slotmem(ap_slotmem_ins
 
     storename = store_filename(slotmem->gpool, slotmem->name);
 
-    rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE,
-                       APR_OS_DEFAULT, slotmem->gpool);
-    if (APR_STATUS_IS_EEXIST(rv)) {
-        apr_file_remove(storename, slotmem->gpool);
+    if (storename) {
         rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE,
                            APR_OS_DEFAULT, slotmem->gpool);
+        if (APR_STATUS_IS_EEXIST(rv)) {
+            apr_file_remove(storename, slotmem->gpool);
+            rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE,
+                               APR_OS_DEFAULT, slotmem->gpool);
+        }
+        if (rv != APR_SUCCESS) {
+            return;
+        }
+        nbytes = (slotmem->desc.size * slotmem->desc.num) +
+                 (slotmem->desc.num * sizeof(char));
+        apr_file_write(fp, slotmem->base, &nbytes);
+        apr_file_close(fp);
     }
-    if (rv != APR_SUCCESS) {
-        return;
-    }
-    nbytes = (slotmem->desc.size * slotmem->desc.num) +
-             (slotmem->desc.num * sizeof(char));
-    apr_file_write(fp, slotmem->base, &nbytes);
-    apr_file_close(fp);
 }
 
 /* should be apr_status_t really */
@@ -166,21 +171,24 @@ static void restore_slotmem(void *ptr, c
     apr_status_t rv;
 
     storename = store_filename(pool, name);
-    rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT,
-                       pool);
-    if (rv == APR_SUCCESS) {
-        apr_finfo_t fi;
-        if (apr_file_info_get(&fi, APR_FINFO_SIZE, fp) == APR_SUCCESS) {
-            if (fi.size == nbytes) {
-                apr_file_read(fp, ptr, &nbytes);
-            }
-            else {
-                apr_file_close(fp);
-                apr_file_remove(storename, pool);
-                return;
+    
+    if (storename) {
+        rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT,
+                           pool);
+        if (rv == APR_SUCCESS) {
+            apr_finfo_t fi;
+            if (apr_file_info_get(&fi, APR_FINFO_SIZE, fp) == APR_SUCCESS) {
+                if (fi.size == nbytes) {
+                    apr_file_read(fp, ptr, &nbytes);
+                }
+                else {
+                    apr_file_close(fp);
+                    apr_file_remove(storename, pool);
+                    return;
+                }
             }
+            apr_file_close(fp);
         }
-        apr_file_close(fp);
     }
 }
 



Mime
View raw message