apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r540039 - in /apr/apr/branches/1.2.x: CHANGES file_io/netware/mktemp.c file_io/unix/filedup.c file_io/unix/mktemp.c file_io/unix/open.c include/arch/netware/apr_arch_file_io.h include/arch/unix/apr_arch_file_io.h
Date Mon, 21 May 2007 06:49:33 GMT
Author: bojan
Date: Sun May 20 23:49:32 2007
New Revision: 540039

URL: http://svn.apache.org/viewvc?view=rev&rev=540039
Log:
Backport r538045 from the trunk.
Discard file buffers when running cleanups for exec.
PR 41119.
Original patches by Davi Arnaut.

Modified:
    apr/apr/branches/1.2.x/CHANGES
    apr/apr/branches/1.2.x/file_io/netware/mktemp.c
    apr/apr/branches/1.2.x/file_io/unix/filedup.c
    apr/apr/branches/1.2.x/file_io/unix/mktemp.c
    apr/apr/branches/1.2.x/file_io/unix/open.c
    apr/apr/branches/1.2.x/include/arch/netware/apr_arch_file_io.h
    apr/apr/branches/1.2.x/include/arch/unix/apr_arch_file_io.h

Modified: apr/apr/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/CHANGES?view=diff&rev=540039&r1=540038&r2=540039
==============================================================================
--- apr/apr/branches/1.2.x/CHANGES (original)
+++ apr/apr/branches/1.2.x/CHANGES Sun May 20 23:49:32 2007
@@ -1,5 +1,8 @@
 Changes for APR 1.2.9
 
+  *) Discard file buffers when running cleanups for exec.
+     PR 41119.  [Davi Arnaut <davi haxent.com.br>, Bojan Smojver]
+
   *) Improve thread safety of assorted file_io functions.
      PR 42400.  [Davi Arnaut <davi haxent.com.br>]
 

Modified: apr/apr/branches/1.2.x/file_io/netware/mktemp.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/file_io/netware/mktemp.c?view=diff&rev=540039&r1=540038&r2=540039
==============================================================================
--- apr/apr/branches/1.2.x/file_io/netware/mktemp.c (original)
+++ apr/apr/branches/1.2.x/file_io/netware/mktemp.c Sun May 20 23:49:32 2007
@@ -42,7 +42,8 @@
                             APR_UREAD | APR_UWRITE, p)) == APR_SUCCESS) {
 
         apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
-                                  apr_unix_file_cleanup, apr_unix_file_cleanup);
+                                  apr_unix_file_cleanup,
+                                  apr_unix_child_file_cleanup);
     }
 
     return rv;

Modified: apr/apr/branches/1.2.x/file_io/unix/filedup.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/file_io/unix/filedup.c?view=diff&rev=540039&r1=540038&r2=540039
==============================================================================
--- apr/apr/branches/1.2.x/file_io/unix/filedup.c (original)
+++ apr/apr/branches/1.2.x/file_io/unix/filedup.c Sun May 20 23:49:32 2007
@@ -91,7 +91,7 @@
 
     apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file),
                               apr_unix_file_cleanup, 
-                              apr_unix_file_cleanup);
+                              apr_unix_child_file_cleanup);
 #ifndef WAITIO_USES_POLL
     /* Start out with no pollset.  apr_wait_for_io_or_timeout() will
      * initialize the pollset if needed.
@@ -144,7 +144,7 @@
                                   apr_unix_file_cleanup,
                                   ((*new_file)->flags & APR_INHERIT)
                                      ? apr_pool_cleanup_null
-                                     : apr_unix_file_cleanup);
+                                     : apr_unix_child_file_cleanup);
     }
 
     old_file->filedes = -1;

Modified: apr/apr/branches/1.2.x/file_io/unix/mktemp.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/file_io/unix/mktemp.c?view=diff&rev=540039&r1=540038&r2=540039
==============================================================================
--- apr/apr/branches/1.2.x/file_io/unix/mktemp.c (original)
+++ apr/apr/branches/1.2.x/file_io/unix/mktemp.c Sun May 20 23:49:32 2007
@@ -203,7 +203,8 @@
     (*fp)->fname = apr_pstrdup(p, template);
 
     apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
-                              apr_unix_file_cleanup, apr_unix_file_cleanup);
+                              apr_unix_file_cleanup,
+                              apr_unix_child_file_cleanup);
 #endif
     return APR_SUCCESS;
 }

Modified: apr/apr/branches/1.2.x/file_io/unix/open.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/file_io/unix/open.c?view=diff&rev=540039&r1=540038&r2=540039
==============================================================================
--- apr/apr/branches/1.2.x/file_io/unix/open.c (original)
+++ apr/apr/branches/1.2.x/file_io/unix/open.c Sun May 20 23:49:32 2007
@@ -26,14 +26,10 @@
 #include "fsio.h"
 #endif
 
-apr_status_t apr_unix_file_cleanup(void *thefile)
+static apr_status_t file_cleanup(apr_file_t *file)
 {
-    apr_file_t *file = thefile;
-    apr_status_t flush_rv = APR_SUCCESS, rv = APR_SUCCESS;
+    apr_status_t rv = APR_SUCCESS;
 
-    if (file->buffered) {
-        flush_rv = apr_file_flush(file);
-    }
     if (close(file->filedes) == 0) {
         file->filedes = -1;
         if (file->flags & APR_DELONCLOSE) {
@@ -60,9 +56,28 @@
         }
     }
 #endif /* !WAITIO_USES_POLL */
+    return rv;
+}
+
+apr_status_t apr_unix_file_cleanup(void *thefile)
+{
+    apr_file_t *file = thefile;
+    apr_status_t flush_rv = APR_SUCCESS, rv = APR_SUCCESS;
+
+    if (file->buffered) {
+        flush_rv = apr_file_flush(file);
+    }
+
+    rv = file_cleanup(file);
+
     return rv != APR_SUCCESS ? rv : flush_rv;
 }
 
+apr_status_t apr_unix_child_file_cleanup(void *thefile)
+{
+    return file_cleanup(thefile);
+}
+
 APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, 
                                         const char *fname, 
                                         apr_int32_t flag, 
@@ -178,7 +193,7 @@
     if (!(flag & APR_FILE_NOCLEANUP)) {
         apr_pool_cleanup_register((*new)->pool, (void *)(*new), 
                                   apr_unix_file_cleanup, 
-                                  apr_unix_file_cleanup);
+                                  apr_unix_child_file_cleanup);
     }
     return APR_SUCCESS;
 }
@@ -288,6 +303,22 @@
 
 APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_unix_file_cleanup)
 
-APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, apr_unix_file_cleanup)
+/* We need to do this by hand instead of using APR_IMPLEMENT_INHERIT_UNSET
+ * because the macro sets both cleanups to the same function, which is not
+ * suitable on Unix (see PR 41119). */
+APR_DECLARE(apr_status_t) apr_file_inherit_unset(apr_file_t *thefile)
+{
+    if (thefile->flags & APR_FILE_NOCLEANUP) {
+        return APR_EINVAL;
+    }
+    if (thefile->flags & APR_INHERIT) {
+        thefile->flags &= ~APR_INHERIT;
+        apr_pool_child_cleanup_set(thefile->pool,
+                                   (void *)thefile,
+                                   apr_unix_file_cleanup,
+                                   apr_unix_child_file_cleanup);
+    }
+    return APR_SUCCESS;
+}
 
 APR_POOL_IMPLEMENT_ACCESSOR(file)

Modified: apr/apr/branches/1.2.x/include/arch/netware/apr_arch_file_io.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/include/arch/netware/apr_arch_file_io.h?view=diff&rev=540039&r1=540038&r2=540039
==============================================================================
--- apr/apr/branches/1.2.x/include/arch/netware/apr_arch_file_io.h (original)
+++ apr/apr/branches/1.2.x/include/arch/netware/apr_arch_file_io.h Sun May 20 23:49:32 2007
@@ -160,6 +160,7 @@
 apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p);
 
 apr_status_t apr_unix_file_cleanup(void *);
+apr_status_t apr_unix_child_file_cleanup(void *);
 
 apr_status_t apr_file_flush_locked(apr_file_t *thefile);
 apr_status_t apr_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted,

Modified: apr/apr/branches/1.2.x/include/arch/unix/apr_arch_file_io.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/include/arch/unix/apr_arch_file_io.h?view=diff&rev=540039&r1=540038&r2=540039
==============================================================================
--- apr/apr/branches/1.2.x/include/arch/unix/apr_arch_file_io.h (original)
+++ apr/apr/branches/1.2.x/include/arch/unix/apr_arch_file_io.h Sun May 20 23:49:32 2007
@@ -143,6 +143,7 @@
 };
 
 apr_status_t apr_unix_file_cleanup(void *);
+apr_status_t apr_unix_child_file_cleanup(void *);
 
 mode_t apr_unix_perms2mode(apr_fileperms_t perms);
 apr_fileperms_t apr_unix_mode2perms(mode_t mode);



Mime
View raw message