Index: srclib/apr/shmem/unix/shm.c =================================================================== --- srclib/apr/shmem/unix/shm.c (revision 1800753) +++ srclib/apr/shmem/unix/shm.c (working copy) @@ -23,19 +23,10 @@ #include "apr_strings.h" #include "apr_hash.h" -#if APR_USE_SHMEM_MMAP_SHM -/* - * For portable use, a shared memory object should be identified by a name of - * the form /somename; that is, a null-terminated string of up to NAME_MAX - * (i.e., 255) characters consisting of an initial slash, followed by one or - * more characters, none of which are slashes. - */ -#ifndef NAME_MAX -#define NAME_MAX 255 -#endif - -/* See proc_mutex.c and sem_open for the reason for all this! */ -static unsigned int rshash (const char *p) { +#if APR_USE_SHMEM_MMAP_SHM+0 || APR_USE_SHMEM_SHMGET+0 +/* See proc_mutex.c, sem_open, and our_ftok for the reason for all this! */ +static unsigned int rshash (const char *p) +{ /* hash function from Robert Sedgwicks 'Algorithms in C' book */ unsigned int b = 378551; unsigned int a = 63689; @@ -48,7 +39,19 @@ return retval; } +#endif +#if APR_USE_SHMEM_MMAP_SHM +/* + * For portable use, a shared memory object should be identified by a name of + * the form /somename; that is, a null-terminated string of up to NAME_MAX + * (i.e., 255) characters consisting of an initial slash, followed by one or + * more characters, none of which are slashes. + */ +#ifndef NAME_MAX +#define NAME_MAX 255 +#endif + static const char *make_shm_open_safe_name(const char *filename, apr_pool_t *pool) { @@ -62,8 +65,8 @@ static const char *make_shm_open_safe_name(const c flen = strlen(filename); h1 = (apr_hashfunc_default(filename, &flen) & 0xffffffff); h2 = (rshash(filename) & 0xffffffff); + return apr_psprintf(pool, "/ShM.%xH%x", h1, h2); - } #endif @@ -72,9 +75,14 @@ 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)); + apr_ssize_t flen; + unsigned int h1, h2; + + flen = strlen(filename); + h1 = apr_hashfunc_default(filename, &flen); + h2 = rshash(filename); + + return ftok(filename, h1 ^ h2); } #endif