From 1e57700c314751b07bc8d9c22a88d8ad6175dc3f Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Tue, 15 Sep 2015 11:01:40 +0000 Subject: [PATCH] mod_slotmem_shm: follow up to r1702450. 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 | 47 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/modules/slotmem/mod_slotmem_shm.c b/modules/slotmem/mod_slotmem_shm.c index bdf42bd4ef..29abe2b9a2 100644 --- a/modules/slotmem/mod_slotmem_shm.c +++ b/modules/slotmem/mod_slotmem_shm.c @@ -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 } }