]> granicus.if.org Git - apache/commitdiff
Backport:
authorGraham Leggett <minfrin@apache.org>
Sun, 25 Mar 2012 20:57:52 +0000 (20:57 +0000)
committerGraham Leggett <minfrin@apache.org>
Sun, 25 Mar 2012 20:57:52 +0000 (20:57 +0000)
mod_slotmem_shm: Support DEFAULT_REL_RUNTIMEDIR for file-based shm.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1305127 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/slotmem/mod_slotmem_shm.c

diff --git a/CHANGES b/CHANGES
index 16eeac9e9c95a14b26fb9da6f02064677b09d941..c2afb292a6b7559b5f193279db0ad21c8bf477f1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,9 @@ Changes with Apache 2.4.2
      envvars: Fix insecure handling of LD_LIBRARY_PATH that could lead to the
      current working directory to be searched for DSOs. [Stefan Fritsch]
 
+  *) mod_slotmem_shm: Support DEFAULT_REL_RUNTIMEDIR for file-based shm.
+     [Jim Jagielski]
+
   *) core: Fix merging of AllowOverrideList and ContentDigest.
      [Stefan Fritsch]
 
diff --git a/STATUS b/STATUS
index 7020bcdea0d4d3a672c1334ff98c102245950bf0..efb0817ed6e01edd1919e1430b32d8ecbd4e0662 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -100,10 +100,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
     2.4.x patch: Trunk patch works (skip docs/log-message-tags/next-number)
     +1: sf, covener, druggeri
 
-  * mod_slotmem_shm: Support DEFAULT_REL_RUNTIMEDIR for file-based shm.
-    Trunk patch: http://svn.apache.org/viewvc?rev=1297560&view=rev
-    2.4.x patch: Trunk patch works
-    +1:  jim, jorton, minfrin
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index cd6ead27e00270b69aa365948aab5a7fd4badd04..b3a5ddcbe0d956e7c2344cb0d4688104d8eb0fab 100644 (file)
@@ -124,14 +124,21 @@ static apr_status_t unixd_set_shm_perms(const char *fname)
  * /abs_name : $abs_name
  *
  */
-static const char *store_filename(apr_pool_t *pool, const char *slotmemname)
+
+#define DEFAULT_SLOTMEM_PREFIX DEFAULT_REL_RUNTIMEDIR "/slotmem-shm-"
+
+#define DEFAULT_SLOTMEM_SUFFIX ".shm"
+
+static const char *slotmem_filename(apr_pool_t *pool, const char *slotmemname)
 {
     const char *fname;
-    if (strcasecmp(slotmemname, "none") == 0) {
+    if (!slotmemname || strcasecmp(slotmemname, "none") == 0) {
         return NULL;
     }
     else if (slotmemname[0] != '/') {
-        fname = ap_server_root_relative(pool, slotmemname);
+        const char *path = apr_pstrcat(pool, DEFAULT_SLOTMEM_PREFIX, slotmemname,
+                                       DEFAULT_SLOTMEM_SUFFIX, NULL);
+        fname = ap_server_root_relative(pool, path);
     }
     else {
         fname = slotmemname;
@@ -146,7 +153,7 @@ static void store_slotmem(ap_slotmem_instance_t *slotmem)
     apr_size_t nbytes;
     const char *storename;
 
-    storename = store_filename(slotmem->gpool, slotmem->name);
+    storename = slotmem_filename(slotmem->gpool, slotmem->name);
 
     if (storename) {
         rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE,
@@ -175,7 +182,7 @@ static void restore_slotmem(void *ptr, const char *name, apr_size_t size,
     apr_size_t nbytes = size;
     apr_status_t rv;
 
-    storename = store_filename(pool, name);
+    storename = slotmem_filename(pool, name);
 
     if (storename) {
         rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT,
@@ -252,7 +259,7 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new,
                                    ap_slotmem_type_t type, apr_pool_t *pool)
 {
 /*    void *slotmem = NULL; */
-    int fbased;
+    int fbased = 1;
     char *ptr;
     sharedslotdesc_t desc;
     ap_slotmem_instance_t *res;
@@ -267,14 +274,8 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new,
     if (gpool == NULL) {
         return APR_ENOSHMAVAIL;
     }
-    if (name) {
-        if (name[0] != '/') {
-            fname = ap_server_root_relative(pool, name);
-        }
-        else {
-            fname = name;
-        }
-
+    fname = slotmem_filename(pool, name);
+    if (fname) {
         /* first try to attach to existing slotmem */
         if (next) {
             for (;;) {
@@ -291,11 +292,11 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new,
         }
     }
     else {
+        fbased = 0;
         fname = "none";
     }
 
     /* first try to attach to existing shared memory */
-    fbased = (name != NULL);
     if (fbased) {
         rv = apr_shm_attach(&shm, fname, gpool);
     }
@@ -395,15 +396,8 @@ static apr_status_t slotmem_attach(ap_slotmem_instance_t **new,
     if (gpool == NULL) {
         return APR_ENOSHMAVAIL;
     }
-    if (name) {
-        if (name[0] == ':') {
-            fname = name;
-        }
-        else {
-            fname = ap_server_root_relative(pool, name);
-        }
-    }
-    else {
+    fname = slotmem_filename(pool, name);
+    if (!fname) {
         return APR_ENOSHMAVAIL;
     }