apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1542731 - in /apr/apr/branches/1.5.x: CHANGES shmem/unix/shm.c
Date Sun, 17 Nov 2013 14:20:11 GMT
Author: jim
Date: Sun Nov 17 14:20:11 2013
New Revision: 1542731

URL: http://svn.apache.org/r1542731
Log:
https://issues.apache.org/bugzilla/show_bug.cgi?id=53996

Modified:
    apr/apr/branches/1.5.x/CHANGES
    apr/apr/branches/1.5.x/shmem/unix/shm.c

Modified: apr/apr/branches/1.5.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/CHANGES?rev=1542731&r1=1542730&r2=1542731&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.5.x/CHANGES [utf-8] Sun Nov 17 14:20:11 2013
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.5.1
 
+  *) When using shmget-based shared memory, the ID used for ftok is
+     now an APR hash of the filename instead of the constant '1'.
+     PR 53996 [Jim Jagielski]
+
   *) Correct a regression in 1.5.0 which affected out-of-tree
      builds on Unix.  [Rainer Jung]
 

Modified: apr/apr/branches/1.5.x/shmem/unix/shm.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/shmem/unix/shm.c?rev=1542731&r1=1542730&r2=1542731&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/shmem/unix/shm.c (original)
+++ apr/apr/branches/1.5.x/shmem/unix/shm.c Sun Nov 17 14:20:11 2013
@@ -20,6 +20,7 @@
 #include "apr_errno.h"
 #include "apr_user.h"
 #include "apr_strings.h"
+#include "apr_hash.h"
 
 static apr_status_t shm_cleanup_owner(void *m_)
 {
@@ -103,6 +104,7 @@ APR_DECLARE(apr_status_t) apr_shm_create
 #if APR_USE_SHMEM_SHMGET
     apr_size_t nbytes;
     key_t shmkey;
+    apr_ssize_t slen;
 #endif
 #if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_SHMGET || \
     APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM
@@ -312,7 +314,9 @@ APR_DECLARE(apr_status_t) apr_shm_create
 
         /* ftok() (on solaris at least) requires that the file actually
          * exist before calling ftok(). */
-        shmkey = ftok(filename, 1);
+        slen = strlen(filename);
+        shmkey = ftok(filename,
+                      (int)apr_hashfunc_default(filename, &slen));
         if (shmkey == (key_t)-1) {
             apr_file_close(file);
             return errno;
@@ -382,6 +386,7 @@ APR_DECLARE(apr_status_t) apr_shm_remove
     apr_file_t *file;  
     key_t shmkey;
     int shmid;
+    apr_ssize_t slen;
 #endif
 
 #if APR_USE_SHMEM_MMAP_TMP
@@ -401,7 +406,9 @@ APR_DECLARE(apr_status_t) apr_shm_remove
 
     /* ftok() (on solaris at least) requires that the file actually
      * exist before calling ftok(). */
-    shmkey = ftok(filename, 1);
+    slen = strlen(filename);
+    shmkey = ftok(filename,
+                  (int)apr_hashfunc_default(filename, &slen));
     if (shmkey == (key_t)-1) {
         goto shm_remove_failed;
     }
@@ -533,6 +540,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach
         apr_file_t *file;   /* file where metadata is stored */
         apr_size_t nbytes;
         key_t shmkey;
+        apr_ssize_t slen;
 
         new_m = apr_palloc(pool, sizeof(apr_shm_t));
 
@@ -555,7 +563,9 @@ APR_DECLARE(apr_status_t) apr_shm_attach
 
         new_m->filename = apr_pstrdup(pool, filename);
         new_m->pool = pool;
-        shmkey = ftok(filename, 1);
+        slen = strlen(filename);
+        shmkey = ftok(filename,
+                      (int)apr_hashfunc_default(filename, &slen));
         if (shmkey == (key_t)-1) {
             return errno;
         }



Mime
View raw message