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/22 18:54:46 UTC

svn commit: r1400951 - in /httpd/httpd/branches/2.4.x: ./ STATUS modules/slotmem/mod_slotmem_shm.c

Author: jim
Date: Mon Oct 22 16:54:46 2012
New Revision: 1400951

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

Use our private function and just allow for conditonal
concat of .persist suffix

Reviewed/backported by: jim
Merge r1386726 from trunk:

Add debug output when slotmem is persisting shm

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/modules/slotmem/mod_slotmem_shm.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1386726,1387085

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1400951&r1=1400950&r2=1400951&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Mon Oct 22 16:54:46 2012
@@ -89,15 +89,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * mod_slotmem_shm: Add debugging output during persist
-     trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1386726
-     2.4.x patch: trunk patch works (minus next-number)
-     +1: jim, rjung, trawick
-
-   * mod_slotmem_shm: Fix handling of persist shm data file naming
-     trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1387085
-      2.4.x patch: trunk patch works
-     +1: jim, rjung, trawick
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]

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=1400951&r1=1400950&r2=1400951&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 Mon Oct 22 16:54:46 2012
@@ -84,6 +84,7 @@ static apr_pool_t *gpool = NULL;
 
 #define DEFAULT_SLOTMEM_PREFIX "slotmem-shm-"
 #define DEFAULT_SLOTMEM_SUFFIX ".shm"
+#define DEFAULT_SLOTMEM_PERSIST_SUFFIX ".persist"
 
 /* apr:shmem/unix/shm.c */
 static apr_status_t unixd_set_shm_perms(const char *fname)
@@ -128,7 +129,8 @@ static apr_status_t unixd_set_shm_perms(
  *
  */
 
-static const char *slotmem_filename(apr_pool_t *pool, const char *slotmemname)
+static const char *slotmem_filename(apr_pool_t *pool, const char *slotmemname,
+                                    int persist)
 {
     const char *fname;
     if (!slotmemname || strcasecmp(slotmemname, "none") == 0) {
@@ -136,12 +138,18 @@ static const char *slotmem_filename(apr_
     }
     else if (slotmemname[0] != '/') {
         const char *filenm = apr_pstrcat(pool, DEFAULT_SLOTMEM_PREFIX,
-                                       slotmemname, DEFAULT_SLOTMEM_SUFFIX, NULL);
+                                         slotmemname, DEFAULT_SLOTMEM_SUFFIX,
+                                         NULL);
         fname = ap_runtime_dir_relative(pool, filenm);
     }
     else {
         fname = slotmemname;
     }
+
+    if (persist) {
+        return apr_pstrcat(pool, fname, DEFAULT_SLOTMEM_PERSIST_SUFFIX,
+                           NULL);
+    }
     return fname;
 }
 
@@ -164,6 +172,11 @@ static void slotmem_clearinuse(ap_slotme
     }
 }
 
+static const char *storemem_filename(apr_pool_t *pool, const char *name)
+{
+    return apr_pstrcat(pool, name, ".persist", NULL);
+}
+
 static void store_slotmem(ap_slotmem_instance_t *slotmem)
 {
     apr_file_t *fp;
@@ -171,7 +184,10 @@ static void store_slotmem(ap_slotmem_ins
     apr_size_t nbytes;
     const char *storename;
 
-    storename = slotmem_filename(slotmem->gpool, slotmem->name);
+    storename = slotmem_filename(slotmem->gpool, slotmem->name, 1);
+
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02334)
+                 "storing %s", storename);
 
     if (storename) {
         rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE,
@@ -189,7 +205,8 @@ static void store_slotmem(ap_slotmem_ins
         }
         nbytes = (slotmem->desc.size * slotmem->desc.num) +
                  (slotmem->desc.num * sizeof(char)) + AP_UNSIGNEDINT_OFFSET;
-        apr_file_write(fp, slotmem->persist, &nbytes);
+        /* XXX: Error handling */
+        apr_file_write_full(fp, slotmem->persist, nbytes, NULL);
         apr_file_close(fp);
     }
 }
@@ -203,7 +220,10 @@ static void restore_slotmem(void *ptr, c
     apr_size_t nbytes = size;
     apr_status_t rv;
 
-    storename = slotmem_filename(pool, name);
+    storename = slotmem_filename(pool, name, 1);
+
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(02335)
+                 "restoring %s", storename);
 
     if (storename) {
         rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT,
@@ -295,7 +315,7 @@ static apr_status_t slotmem_create(ap_sl
     if (gpool == NULL) {
         return APR_ENOSHMAVAIL;
     }
-    fname = slotmem_filename(pool, name);
+    fname = slotmem_filename(pool, name, 0);
     if (fname) {
         /* first try to attach to existing slotmem */
         if (next) {
@@ -420,7 +440,7 @@ static apr_status_t slotmem_attach(ap_sl
     if (gpool == NULL) {
         return APR_ENOSHMAVAIL;
     }
-    fname = slotmem_filename(pool, name);
+    fname = slotmem_filename(pool, name, 0);
     if (!fname) {
         return APR_ENOSHMAVAIL;
     }
@@ -715,4 +735,3 @@ AP_DECLARE_MODULE(slotmem_shm) = {
     NULL,                       /* command apr_table_t */
     ap_slotmem_shm_register_hook  /* register hooks */
 };
-