diff options
author | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2004-09-21 15:02:00 +0000 |
---|---|---|
committer | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2004-09-21 15:02:00 +0000 |
commit | 0e4c180a8364f84c5c894c0787b60b4b14d2e454 (patch) | |
tree | 81aa0caa9bc276d01cd83209c3d3f368c3e99bfd | |
parent | 3b6f1940b320afa6cc75a5e4d92fdf93e4d17230 (diff) | |
download | libapr-0e4c180a8364f84c5c894c0787b60b4b14d2e454.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: http://svn.apache.org/repos/asf/apr/apr/trunk@65337 13f79535-47bb-0310-9956-ffa450edef68
-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 */ |