Return-Path: X-Original-To: apmail-apr-commits-archive@www.apache.org Delivered-To: apmail-apr-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7ABC01071F for ; Sat, 25 Jan 2014 20:35:26 +0000 (UTC) Received: (qmail 19732 invoked by uid 500); 25 Jan 2014 20:35:24 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 19638 invoked by uid 500); 25 Jan 2014 20:35:24 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 19631 invoked by uid 99); 25 Jan 2014 20:35:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Jan 2014 20:35:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Jan 2014 20:35:23 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1532C238889B; Sat, 25 Jan 2014 20:35:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1561394 - in /apr/apr/trunk: CHANGES shmem/unix/shm.c Date: Sat, 25 Jan 2014 20:35:02 -0000 To: commits@apr.apache.org From: jim@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140125203503.1532C238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jim Date: Sat Jan 25 20:35:02 2014 New Revision: 1561394 URL: http://svn.apache.org/r1561394 Log: Okey dokey... how we gen the key isn't part of our ABI, so we can fix it without breaking it. Modified: apr/apr/trunk/CHANGES apr/apr/trunk/shmem/unix/shm.c Modified: apr/apr/trunk/CHANGES URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1561394&r1=1561393&r2=1561394&view=diff ============================================================================== --- apr/apr/trunk/CHANGES [utf-8] (original) +++ apr/apr/trunk/CHANGES [utf-8] Sat Jan 25 20:35:02 2014 @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes for APR 2.0.0 + *) When using shmget-based shared memory, the ID used for ftok is + now an APR hash of the filename instead of the constant '1'. + We do this to help avoid collisions. PR 53996 [Jim Jagielski] + *) Fix POSIX shared memory (shm_open) use for named shared memory. Includes adding '--enable-posix-shm' to force POSIX shm if available, and OSX compatibility. PR 55928. Modified: apr/apr/trunk/shmem/unix/shm.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/shmem/unix/shm.c?rev=1561394&r1=1561393&r2=1561394&view=diff ============================================================================== --- apr/apr/trunk/shmem/unix/shm.c (original) +++ apr/apr/trunk/shmem/unix/shm.c Sat Jan 25 20:35:02 2014 @@ -67,6 +67,17 @@ static const char *make_shm_open_safe_na } #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 /* ftok() (on solaris at least) requires that the file actually * exist before calling ftok(). */ - new_m->shmkey = ftok(filename, 1); + new_m->shmkey = our_ftok(filename); if (new_m->shmkey == (key_t)-1) { apr_file_close(file); return errno; @@ -451,7 +462,7 @@ 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); + shmkey = our_ftok(filename); if (shmkey == (key_t)-1) { goto shm_remove_failed; } @@ -623,7 +634,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach new_m->filename = apr_pstrdup(pool, filename); new_m->pool = pool; - new_m->shmkey = ftok(filename, 1); + new_m->shmkey = our_ftok(filename); if (new_m->shmkey == (key_t)-1) { return errno; }