apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r747167 - in /apr/apr/branches/1.3.x: ./ CHANGES file_io/unix/open.c
Date Mon, 23 Feb 2009 22:28:27 GMT
Author: bojan
Date: Mon Feb 23 22:28:25 2009
New Revision: 747167

URL: http://svn.apache.org/viewvc?rev=747167&view=rev
Log:
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().

Modified:
    apr/apr/branches/1.3.x/   (props changed)
    apr/apr/branches/1.3.x/CHANGES
    apr/apr/branches/1.3.x/file_io/unix/open.c

Propchange: apr/apr/branches/1.3.x/
------------------------------------------------------------------------------
    svn:mergeinfo = /apr/apr/trunk:712674

Modified: apr/apr/branches/1.3.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/CHANGES?rev=747167&r1=747166&r2=747167&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.3.x/CHANGES [utf-8] Mon Feb 23 22:28:25 2009
@@ -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>]
 

Modified: apr/apr/branches/1.3.x/file_io/unix/open.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/file_io/unix/open.c?rev=747167&r1=747166&r2=747167&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/file_io/unix/open.c (original)
+++ apr/apr/branches/1.3.x/file_io/unix/open.c Mon Feb 23 22:28:25 2009
@@ -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, 



Mime
View raw message