diff options
author | bojan <bojan@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-03 00:15:38 +0000 |
---|---|---|
committer | bojan <bojan@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-03 00:15:38 +0000 |
commit | f7d7d9e5b1f0fe08ba7a3668e1369ccd174ecaca (patch) | |
tree | f7d4b873d46d4e7722130b54640fa66f0fb5325b | |
parent | 6b7e52f2f18a57cbac181b4ef59598c45c6db2fd (diff) | |
download | libapr-f7d7d9e5b1f0fe08ba7a3668e1369ccd174ecaca.tar.gz |
Backport r661146, 662114 and 662300 from the trunk.
If the named resource was removed by apr_shm_remove(), it may not be there.
Ignore EINVAL from shmctl in shm_cleanup_owner
This fixes the testcase, but doesn't feel like the end of the story:
both this and r661146 feel like sticking plaster over something deeper.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.3.x@662604 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | include/arch/unix/apr_arch_shm.h | 3 | ||||
-rw-r--r-- | shmem/unix/shm.c | 16 |
2 files changed, 16 insertions, 3 deletions
diff --git a/include/arch/unix/apr_arch_shm.h b/include/arch/unix/apr_arch_shm.h index dbd9b9bc5..bbd373e36 100644 --- a/include/arch/unix/apr_arch_shm.h +++ b/include/arch/unix/apr_arch_shm.h @@ -27,6 +27,9 @@ #include "apr_network_io.h" #include "apr_portable.h" +#if APR_HAVE_UNISTD_H +#include <unistd.h> +#endif #ifdef HAVE_SYS_MMAN_H #include <sys/mman.h> #endif diff --git a/shmem/unix/shm.c b/shmem/unix/shm.c index 95d1c053f..14bb34491 100644 --- a/shmem/unix/shm.c +++ b/shmem/unix/shm.c @@ -49,7 +49,12 @@ static apr_status_t shm_cleanup_owner(void *m_) if (munmap(m->base, m->realsize) == -1) { return errno; } - return apr_file_remove(m->filename, m->pool); + if (access(m->filename, F_OK)) { + return APR_SUCCESS; + } + else { + return apr_file_remove(m->filename, m->pool); + } #endif #if APR_USE_SHMEM_MMAP_SHM if (munmap(m->base, m->realsize) == -1) { @@ -64,13 +69,18 @@ static apr_status_t shm_cleanup_owner(void *m_) /* 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(m->shmid, IPC_RMID, NULL) == -1) { + if (shmctl(m->shmid, IPC_RMID, NULL) == -1 && errno != EINVAL) { return errno; } if (shmdt(m->base) == -1) { return errno; } - return apr_file_remove(m->filename, m->pool); + if (access(m->filename, F_OK)) { + return APR_SUCCESS; + } + else { + return apr_file_remove(m->filename, m->pool); + } #endif } |