apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1183732 - in /apr/apr/branches/1.4.x: ./ CHANGES file_io/unix/open.c
Date Sat, 15 Oct 2011 21:34:25 GMT
Author: sf
Date: Sat Oct 15 21:34:24 2011
New Revision: 1183732

URL: http://svn.apache.org/viewvc?rev=1183732&view=rev
Log:
Backport r1183698:

    Avoid fcntl() calls if support for O_CLOEXEC works.
    PR: 48557
    Submitted by: Mike Frysinger <vapier gentoo org>

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

Propchange: apr/apr/branches/1.4.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 15 21:34:24 2011
@@ -1,2 +1,2 @@
 /apr/apr/branches/1.5.x:1083592,1183724
-/apr/apr/trunk:733052,747990,748361,748371,748565,748888,748902,748988,749810,760443,782838,783398,783958,784633,784773,788588,793192-793193,794118,794485,795267,799497,800627,809745,809854,810472,811455,813063,821306,829490,831641,835607,905040,908427,910419,917837-917838,979891,983618,990435,1072165,1078845,1183683,1183685-1183686,1183688
+/apr/apr/trunk:733052,747990,748361,748371,748565,748888,748902,748988,749810,760443,782838,783398,783958,784633,784773,788588,793192-793193,794118,794485,795267,799497,800627,809745,809854,810472,811455,813063,821306,829490,831641,835607,905040,908427,910419,917837-917838,979891,983618,990435,1072165,1078845,1183683,1183685-1183686,1183688,1183698

Modified: apr/apr/branches/1.4.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/CHANGES?rev=1183732&r1=1183731&r2=1183732&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.4.x/CHANGES [utf-8] Sat Oct 15 21:34:24 2011
@@ -1,6 +1,9 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.4.6
 
+  *) apr_file_open: Avoid fcntl() calls if support for O_CLOEXEC works.
+     PR 48557. [Mike Frysinger <vapier gentoo org>]
+
   *) apr_dir_make_recursive: Fix race condition that could lead to EEXIST
      being returned. PR 51254. [William Lee <william lee rainstor com>,
      Wim Lewis <wiml omnigroup com>]

Modified: apr/apr/branches/1.4.x/file_io/unix/open.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/file_io/unix/open.c?rev=1183732&r1=1183731&r2=1183732&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/file_io/unix/open.c (original)
+++ apr/apr/branches/1.4.x/file_io/unix/open.c Sat Oct 15 21:34:24 2011
@@ -171,19 +171,29 @@ APR_DECLARE(apr_status_t) apr_file_open(
        return errno;
     }
     if (!(flag & APR_FOPEN_NOCLEANUP)) {
-        int flags;
-
-        if ((flags = fcntl(fd, F_GETFD)) == -1) {
-            close(fd);
-            return errno;
-        }
+#ifdef O_CLOEXEC
+        static int has_o_cloexec = 0;
+        if (!has_o_cloexec)
+#endif
+        {
+            int flags;
 
-        if ((flags & FD_CLOEXEC) == 0) {
-            flags |= FD_CLOEXEC;
-            if (fcntl(fd, F_SETFD, flags) == -1) {
+            if ((flags = fcntl(fd, F_GETFD)) == -1) {
                 close(fd);
                 return errno;
             }
+            if ((flags & FD_CLOEXEC) == 0) {
+                flags |= FD_CLOEXEC;
+                if (fcntl(fd, F_SETFD, flags) == -1) {
+                    close(fd);
+                    return errno;
+                }
+            }
+#ifdef O_CLOEXEC
+            else {
+                has_o_cloexec = 1;
+            }
+#endif
         }
     }
 



Mime
View raw message