diff options
author | bojan <bojan@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-23 22:28:25 +0000 |
---|---|---|
committer | bojan <bojan@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-23 22:28:25 +0000 |
commit | 29bd15dcdc5bc30646e891a122e1287c9a1d07e3 (patch) | |
tree | 5334c033bdb6c189919dd1c758efa1a11a40365a | |
parent | 51f0e6e0de88793ab9707c8ce73bc395d834d264 (diff) | |
download | libapr-29bd15dcdc5bc30646e891a122e1287c9a1d07e3.tar.gz |
Backport r712674 from the trunk.
Fix a bug with the APR_DELONCLOSE flag. Child processes were (also)
unlinking the file. Badness ensued.
* file_io/unix/open.c:
(file_cleanup): add new parameter to tell whether the function was
invoked by the child's cleanup, or the regular cleanup. use it to
determine whether to unlink the file.
(apr_unix_file_cleanup, apr_unix_child_file_cleanup): pass appropriate
value to file_cleanup().
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.3.x@747167 13f79535-47bb-0310-9956-ffa450edef68
-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, |