You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by gs...@apache.org on 2008/11/10 16:20:02 UTC
svn commit: r712674 - /apr/apr/trunk/file_io/unix/open.c
Author: gstein
Date: Mon Nov 10 07:20:02 2008
New Revision: 712674
URL: http://svn.apache.org/viewvc?rev=712674&view=rev
Log:
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().
Modified:
apr/apr/trunk/file_io/unix/open.c
Modified: apr/apr/trunk/file_io/unix/open.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/open.c?rev=712674&r1=712673&r2=712674&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/open.c (original)
+++ apr/apr/trunk/file_io/unix/open.c Mon Nov 10 07:20:02 2008
@@ -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 @@
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,