]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_slotmem_shm: follow up to r1702450.
authorYann Ylavic <ylavic@apache.org>
Tue, 15 Sep 2015 11:01:40 +0000 (11:01 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 15 Sep 2015 11:01:40 +0000 (11:01 +0000)
r1702450 changed the behaviour of slotmem_{create,attach}() when given
given an absolute (SHM file )name.
Don't mangle the SHM file name in this case, it's up to the caller to
provide a unique name per call when this matters.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1703149 13f79535-47bb-0310-9956-ffa450edef68

modules/slotmem/mod_slotmem_shm.c

index bdf42bd4ef3072fa2e9aca5a363435fa907beb80..29abe2b9a29103c9d37b49f341cf5277fba9e500 100644 (file)
@@ -112,36 +112,43 @@ static int slotmem_filenames(apr_pool_t *pool,
     const char *fname = NULL, *pname = NULL;
 
     if (slotname && *slotname && strcasecmp(slotname, "none") != 0) {
-        fname = slotname;
-#if SLOTMEM_UNLINK_SEMANTIC
-        /* Reuse the same file name for each generation. */
-        fname = apr_pstrcat(pool, DEFAULT_SLOTMEM_PREFIX,
-                            fname, DEFAULT_SLOTMEM_SUFFIX,
-                            NULL);
-#else
-        /* Each generation needs its own file name. */
-        {
+        if (slotname[0] != '/') {
+#if !SLOTMEM_UNLINK_SEMANTIC
+            /* Each generation needs its own file name. */
             int generation = 0;
             ap_mpm_query(AP_MPMQ_GENERATION, &generation);
             fname = apr_psprintf(pool, "%s%s_%x%s", DEFAULT_SLOTMEM_PREFIX,
-                                 fname, generation, DEFAULT_SLOTMEM_SUFFIX);
-        }
+                                 slotname, generation, DEFAULT_SLOTMEM_SUFFIX);
+#else
+            /* Reuse the same file name for each generation. */
+            fname = apr_pstrcat(pool, DEFAULT_SLOTMEM_PREFIX,
+                                slotname, DEFAULT_SLOTMEM_SUFFIX,
+                                NULL);
 #endif
-        fname = ap_runtime_dir_relative(pool, fname);
+            fname = ap_runtime_dir_relative(pool, fname);
+        }
+        else {
+            /* Don't mangle the file name if given an absolute path, it's
+             * up to the caller to provide a unique name when necessary.
+             */
+            fname = slotname;
+        }
 
         if (persistname) {
             /* Persisted file names are immutable... */
-#if SLOTMEM_UNLINK_SEMANTIC
+#if !SLOTMEM_UNLINK_SEMANTIC
+            if (slotname[0] != '/') {
+                pname = apr_pstrcat(pool, DEFAULT_SLOTMEM_PREFIX,
+                                    slotname, DEFAULT_SLOTMEM_SUFFIX,
+                                    DEFAULT_SLOTMEM_PERSIST_SUFFIX,
+                                    NULL);
+                pname = ap_runtime_dir_relative(pool, pname);
+            }
+            else
+#endif
             pname = apr_pstrcat(pool, fname,
                                 DEFAULT_SLOTMEM_PERSIST_SUFFIX,
                                 NULL);
-#else
-            pname = apr_pstrcat(pool, DEFAULT_SLOTMEM_PREFIX,
-                                slotname, DEFAULT_SLOTMEM_SUFFIX,
-                                DEFAULT_SLOTMEM_PERSIST_SUFFIX,
-                                NULL);
-            pname = ap_runtime_dir_relative(pool, pname);
-#endif
         }
     }