From f7d7d9e5b1f0fe08ba7a3668e1369ccd174ecaca Mon Sep 17 00:00:00 2001 From: bojan Date: Tue, 3 Jun 2008 00:15:38 +0000 Subject: =?UTF-8?q?Backport=20r661146=EF=BB=BF,=20662114=20and=20662300=20?= =?UTF-8?q?from=20the=20trunk.=20If=20the=20named=20resource=20was=20remov?= =?UTF-8?q?ed=20by=20apr=5Fshm=5Fremove(),=20it=20may=20not=20be=20there.?= =?UTF-8?q?=20Ignore=20EINVAL=20from=20shmctl=20in=20shm=5Fcleanup=5Fowner?= =?UTF-8?q?=20This=20fixes=20the=20testcase,=20but=20doesn't=20feel=20like?= =?UTF-8?q?=20the=20end=20of=20the=20story:=20both=20this=20and=20r661146?= =?UTF-8?q?=20feel=20like=20sticking=20plaster=20over=20something=20deeper?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.3.x@662604 13f79535-47bb-0310-9956-ffa450edef68 --- include/arch/unix/apr_arch_shm.h | 3 +++ 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 +#endif #ifdef HAVE_SYS_MMAN_H #include #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 } -- cgit v1.2.1