httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1297560 - /httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c
Date Tue, 06 Mar 2012 16:20:18 GMT
Author: jim
Date: Tue Mar  6 16:20:17 2012
New Revision: 1297560

URL: http://svn.apache.org/viewvc?rev=1297560&view=rev
Log:
Allow for DEFAULT_REL_RUNTIMEDIR ala socache... prevent perm issues
with some configs

Modified:
    httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c

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=1297560&r1=1297559&r2=1297560&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c (original)
+++ httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c Tue Mar  6 16:20:17 2012
@@ -124,14 +124,21 @@ static apr_status_t unixd_set_shm_perms(
  * /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_ins
     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, c
     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_sl
                                    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_sl
     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_sl
         }
     }
     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_sl
     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;
     }
 



Mime
View raw message