From cd4cac6b8d20daa7c6662835ce0b79b8d72c1093 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Tue, 21 Sep 2004 15:02:00 +0000 Subject: * 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. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@65337 13f79535-47bb-0310-9956-ffa450edef68 --- shmem/unix/shm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'shmem') diff --git a/shmem/unix/shm.c b/shmem/unix/shm.c index ec6e2b41f..db0dc5e79 100644 --- a/shmem/unix/shm.c +++ b/shmem/unix/shm.c @@ -385,20 +385,28 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, * 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 */ -- cgit v1.2.1