summaryrefslogtreecommitdiff
path: root/shmem
diff options
context:
space:
mode:
authorjim <jim@13f79535-47bb-0310-9956-ffa450edef68>2014-01-25 20:40:27 +0000
committerjim <jim@13f79535-47bb-0310-9956-ffa450edef68>2014-01-25 20:40:27 +0000
commit416ff3ff5abbe4fe06a2d2e8085667bb99a9bac6 (patch)
treefc1924d7885e7110ab87f2b15a0128c1c1e4b5b7 /shmem
parent44f8985c30628aeefcdac7c6f171ed82e1ae9dbd (diff)
downloadlibapr-416ff3ff5abbe4fe06a2d2e8085667bb99a9bac6.tar.gz
Merge r1561394 from trunk:
Okey dokey... how we gen the key isn't part of our ABI, so we can fix it without breaking it. Reviewed/backported by: jim git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1561395 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'shmem')
-rw-r--r--shmem/unix/shm.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/shmem/unix/shm.c b/shmem/unix/shm.c
index 9ec33bbae..a4f6d6afb 100644
--- a/shmem/unix/shm.c
+++ b/shmem/unix/shm.c
@@ -66,6 +66,17 @@ static const char *make_shm_open_safe_name(const char *filename,
}
#endif
+#if APR_USE_SHMEM_SHMGET
+static key_t our_ftok(const char *filename)
+{
+ /* to help avoid collisions while still using
+ * an easily recreated proj_id */
+ apr_ssize_t slen = strlen(filename);
+ return ftok(filename,
+ (int)apr_hashfunc_default(filename, &slen));
+}
+#endif
+
static apr_status_t shm_cleanup_owner(void *m_)
{
apr_shm_t *m = (apr_shm_t *)m_;
@@ -361,7 +372,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
/* ftok() (on solaris at least) requires that the file actually
* exist before calling ftok(). */
- shmkey = ftok(filename, 1);
+ shmkey = our_ftok(filename);
if (shmkey == (key_t)-1) {
apr_file_close(file);
return errno;
@@ -451,7 +462,7 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename,
/* ftok() (on solaris at least) requires that the file actually
* exist before calling ftok(). */
- shmkey = ftok(filename, 1);
+ shmkey = our_ftok(filename);
if (shmkey == (key_t)-1) {
goto shm_remove_failed;
}
@@ -624,7 +635,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
new_m->filename = apr_pstrdup(pool, filename);
new_m->pool = pool;
- shmkey = ftok(filename, 1);
+ shmkey = our_ftok(filename);
if (shmkey == (key_t)-1) {
return errno;
}