diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | file_io/unix/open.c | 10 |
2 files changed, 9 insertions, 4 deletions
@@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes for APR 1.3.4 + *) Fix a bug with the APR_DELONCLOSE flag. Child processes were (also) + unlinking the file. [Greg Stein] + *) Fix compilation error on systems that do not have IPV6. PR 46601 [Julien Charbon <jch 4js.com>] diff --git a/file_io/unix/open.c b/file_io/unix/open.c index e84045045..394712740 100644 --- a/file_io/unix/open.c +++ b/file_io/unix/open.c @@ -26,13 +26,15 @@ #include "fsio.h" #endif -static apr_status_t file_cleanup(apr_file_t *file) +static apr_status_t file_cleanup(apr_file_t *file, int is_child) { apr_status_t rv = APR_SUCCESS; if (close(file->filedes) == 0) { file->filedes = -1; - if (file->flags & APR_DELONCLOSE) { + + /* Only the parent process should delete the file! */ + if (!is_child && (file->flags & APR_DELONCLOSE)) { unlink(file->fname); } #if APR_HAS_THREADS @@ -68,14 +70,14 @@ apr_status_t apr_unix_file_cleanup(void *thefile) flush_rv = apr_file_flush(file); } - rv = file_cleanup(file); + rv = file_cleanup(file, 0); return rv != APR_SUCCESS ? rv : flush_rv; } apr_status_t apr_unix_child_file_cleanup(void *thefile) { - return file_cleanup(thefile); + return file_cleanup(thefile, 1); } APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, |