Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 29869 invoked from network); 6 Nov 2007 03:58:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2007 03:58:48 -0000 Received: (qmail 60279 invoked by uid 500); 6 Nov 2007 03:58:36 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 60239 invoked by uid 500); 6 Nov 2007 03:58:36 -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 60228 invoked by uid 99); 6 Nov 2007 03:58:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 19:58:36 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2007 03:59:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0EA3B1A9838; Mon, 5 Nov 2007 19:58:25 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r592258 - in /apr/apr/trunk: include/apr_shm.h test/testshm.c Date: Tue, 06 Nov 2007 03:58:24 -0000 To: commits@apr.apache.org From: wrowe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071106035825.0EA3B1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: wrowe Date: Mon Nov 5 19:58:22 2007 New Revision: 592258 URL: http://svn.apache.org/viewvc?rev=592258&view=rev Log: More effectively explain apr_shm_remove, and the hints that it provides to the caller. Document these assumptions by way of a proper test case, cleaning up irrespective of which implementation is available on this platform. Modified: apr/apr/trunk/include/apr_shm.h apr/apr/trunk/test/testshm.c Modified: apr/apr/trunk/include/apr_shm.h URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_shm.h?rev=592258&r1=592257&r2=592258&view=diff ============================================================================== --- apr/apr/trunk/include/apr_shm.h (original) +++ apr/apr/trunk/include/apr_shm.h Mon Nov 5 19:58:22 2007 @@ -71,14 +71,19 @@ apr_pool_t *pool); /** - * Remove file associated with a shared memory segment. + * Remove named resource associated with a shared memory segment, + * preventing attachments to the resource, but not destroying it. * @param filename The filename associated with shared-memory segment which * needs to be removed * @param pool The pool used for file operations * @remark This function is only supported on platforms which support * name-based shared memory segments, and will return APR_ENOTIMPL on * platforms without such support. Removing the file while the shm - * is in use (prior to apr_shm_destroy) is non-portable. + * is in use is not entirely portable, caller may use this to enhance + * obscurity of the resource, but be prepared for the the call to fail, + * and for concurrent attempts to create a resource of the same name + * to also fail. The pool cleanup of apr_shm_create (apr_shm_destroy) + * also removes the named resource. */ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, apr_pool_t *pool); Modified: apr/apr/trunk/test/testshm.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testshm.c?rev=592258&r1=592257&r2=592258&view=diff ============================================================================== --- apr/apr/trunk/test/testshm.c (original) +++ apr/apr/trunk/test/testshm.c Mon Nov 5 19:58:22 2007 @@ -221,7 +221,7 @@ static void test_named_remove(abts_case *tc, void *data) { apr_status_t rv; - apr_shm_t *shm; + apr_shm_t *shm, *shm2; apr_shm_remove(SHARED_FILENAME, p); @@ -233,20 +233,29 @@ ABTS_PTR_NOTNULL(tc, shm); rv = apr_shm_remove(SHARED_FILENAME, p); - APR_ASSERT_SUCCESS(tc, "Error removing shared memory block", rv); - if (rv != APR_SUCCESS) { - return ; - } - rv = apr_shm_create(&shm, SHARED_SIZE, SHARED_FILENAME, p); - APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); - if (rv != APR_SUCCESS) { - return; + /* On platforms which acknowledge the removal of the shared resource, + * ensure another of the same name may be created after removal; + */ + if (rv == APR_SUCCESS) + { + rv = apr_shm_create(&shm2, SHARED_SIZE, SHARED_FILENAME, p); + APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); + if (rv != APR_SUCCESS) { + return; + } + ABTS_PTR_NOTNULL(tc, shm2); + + rv = apr_shm_destroy(shm2); + APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv); } - ABTS_PTR_NOTNULL(tc, shm); rv = apr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv); + + /* Now ensure no named resource remains which we may attach to */ + rv = apr_shm_attach(&shm, SHARED_FILENAME, p); + ABTS_TRUE(tc, rv != 0); } #endif