From cvs-return-6108-apmail-apr-cvs-archive=apr.apache.org@apr.apache.org Tue Sep 21 15:02:47 2004 Return-Path: Delivered-To: apmail-apr-cvs-archive@www.apache.org Received: (qmail 5090 invoked from network); 21 Sep 2004 15:02:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 21 Sep 2004 15:02:46 -0000 Received: (qmail 13739 invoked by uid 500); 21 Sep 2004 15:02:07 -0000 Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 13619 invoked by uid 500); 21 Sep 2004 15:02:06 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 13470 invoked by uid 99); 21 Sep 2004 15:02:04 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Date: 21 Sep 2004 15:02:01 -0000 Message-ID: <20040921150201.4540.qmail@minotaur.apache.org> From: jorton@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/shmem/unix shm.c X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N jorton 2004/09/21 08:02:01 Modified: shmem/unix shm.c Log: * shmem/unix/shm.c (apr_shm_remove): Ensure that the file is removed even if the shm segment has already been destroyed; close the file before returning. Revision Changes Path 1.28 +11 -3 apr/shmem/unix/shm.c Index: shm.c =================================================================== RCS file: /home/cvs/apr/shmem/unix/shm.c,v retrieving revision 1.27 retrieving revision 1.28 diff -d -w -u -r1.27 -r1.28 --- shm.c 1 Jun 2004 10:03:50 -0000 1.27 +++ shm.c 21 Sep 2004 15:02:00 -0000 1.28 @@ -385,20 +385,28 @@ * exist before calling ftok(). */ shmkey = ftok(filename, 1); if (shmkey == (key_t)-1) { - return errno; + goto shm_remove_failed; } + apr_file_close(file); + if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) < 0) { - return errno; + goto shm_remove_failed; } /* Indicate that the segment is to be destroyed as soon * as all processes have detached. This also disallows any * new attachments to the segment. */ if (shmctl(shmid, IPC_RMID, NULL) == -1) { - return errno; + goto shm_remove_failed; } return apr_file_remove(filename, pool); + +shm_remove_failed: + status = errno; + /* ensure the file has been removed anyway. */ + apr_file_remove(filename, pool); + return status; #endif /* No support for anonymous shm */