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 */