diff options
author | Joe Orton <jorton@apache.org> | 2004-09-21 15:02:00 +0000 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2004-09-21 15:02:00 +0000 |
commit | cd4cac6b8d20daa7c6662835ce0b79b8d72c1093 (patch) | |
tree | 81aa0caa9bc276d01cd83209c3d3f368c3e99bfd /shmem | |
parent | 23fc35b7fb01e76c3606c842d80293c5e44f6acb (diff) | |
download | apr-cd4cac6b8d20daa7c6662835ce0b79b8d72c1093.tar.gz |
* 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
Diffstat (limited to 'shmem')
-rw-r--r-- | shmem/unix/shm.c | 14 |
1 files changed, 11 insertions, 3 deletions
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 */ |