summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/arch/unix/apr_arch_shm.h3
-rw-r--r--shmem/unix/shm.c16
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
}