apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r748371 - in /apr/apr/trunk: file_io/netware/mktemp.c file_io/unix/mktemp.c file_io/unix/open.c include/arch/unix/apr_arch_inherit.h network_io/unix/sockets.c poll/unix/epoll.c poll/unix/kqueue.c poll/unix/pollset.c poll/unix/port.c
Date Fri, 27 Feb 2009 01:34:55 GMT
Author: bojan
Date: Fri Feb 27 01:34:54 2009
New Revision: 748371

URL: http://svn.apache.org/viewvc?rev=748371&view=rev
Log:
Unroll APR_SET_FD_CLOEXEC macro.

Modified:
    apr/apr/trunk/file_io/netware/mktemp.c
    apr/apr/trunk/file_io/unix/mktemp.c
    apr/apr/trunk/file_io/unix/open.c
    apr/apr/trunk/include/arch/unix/apr_arch_inherit.h
    apr/apr/trunk/network_io/unix/sockets.c
    apr/apr/trunk/poll/unix/epoll.c
    apr/apr/trunk/poll/unix/kqueue.c
    apr/apr/trunk/poll/unix/pollset.c
    apr/apr/trunk/poll/unix/port.c

Modified: apr/apr/trunk/file_io/netware/mktemp.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/netware/mktemp.c?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/file_io/netware/mktemp.c (original)
+++ apr/apr/trunk/file_io/netware/mktemp.c Fri Feb 27 01:34:54 2009
@@ -44,7 +44,15 @@
 
 
 	if (!(flags & APR_FILE_NOCLEANUP)) {
-            APR_SET_FD_CLOEXEC((*fp)->filedes);
+            int flags;
+
+            if ((flags = fcntl((*fp)->filedes, F_GETFD)) == -1)
+                return errno;
+
+            flags |= FD_CLOEXEC;
+            if (fcntl((*fp)->filedes, F_SETFD, flags) == -1)
+                return errno;
+
 	    apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
 				      apr_unix_file_cleanup,
 				      apr_unix_child_file_cleanup);

Modified: apr/apr/trunk/file_io/unix/mktemp.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/mktemp.c?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/mktemp.c (original)
+++ apr/apr/trunk/file_io/unix/mktemp.c Fri Feb 27 01:34:54 2009
@@ -204,7 +204,15 @@
     (*fp)->fname = apr_pstrdup(p, template);
 
     if (!(flags & APR_FILE_NOCLEANUP)) {
-        APR_SET_FD_CLOEXEC(fd);
+        int flags;
+
+        if ((flags = fcntl(fd, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(fd, F_SETFD, flags) == -1)
+            return errno;
+
         apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
                                   apr_unix_file_cleanup,
                                   apr_unix_child_file_cleanup);

Modified: apr/apr/trunk/file_io/unix/open.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/open.c?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/open.c (original)
+++ apr/apr/trunk/file_io/unix/open.c Fri Feb 27 01:34:54 2009
@@ -164,7 +164,14 @@
        return errno;
     }
     if (!(flag & APR_FILE_NOCLEANUP)) {
-	APR_SET_FD_CLOEXEC(fd);
+        int flags;
+
+        if ((flags = fcntl(fd, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(fd, F_SETFD, flags) == -1)
+            return errno;
     }
 
     (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t));
@@ -348,7 +355,15 @@
         return APR_EINVAL;
     }
     if (thefile->flags & APR_INHERIT) {
-        APR_SET_FD_CLOEXEC(thefile->filedes);
+        int flags;
+
+        if ((flags = fcntl(thefile->filedes, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(thefile->filedes, F_SETFD, flags) == -1)
+            return errno;
+
         thefile->flags &= ~APR_INHERIT;
         apr_pool_child_cleanup_set(thefile->pool,
                                    (void *)thefile,

Modified: apr/apr/trunk/include/arch/unix/apr_arch_inherit.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/arch/unix/apr_arch_inherit.h?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/include/arch/unix/apr_arch_inherit.h (original)
+++ apr/apr/trunk/include/arch/unix/apr_arch_inherit.h Fri Feb 27 01:34:54 2009
@@ -41,23 +41,18 @@
     return APR_SUCCESS;                                             \
 }
 
-#define APR_SET_FD_CLOEXEC(fd)                                      \
-do {                                                                \
-    int flags;                                                      \
-    if ((flags = fcntl(fd, F_GETFD)) == -1)                         \
-        return errno;                                               \
-    flags |= FD_CLOEXEC;                                            \
-    if (fcntl(fd, F_SETFD, flags) == -1)                            \
-        return errno;                                               \
-} while (0)
-
 #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup)      \
 apr_status_t apr_##name##_inherit_unset(apr_##name##_t *the##name)  \
 {                                                                   \
     if (the##name->flag & APR_FILE_NOCLEANUP)                       \
         return APR_EINVAL;                                          \
     if (the##name->flag & APR_INHERIT) {                            \
-        APR_SET_FD_CLOEXEC(the##name->name##des);                   \
+        int flags;                                                  \
+        if ((flags = fcntl(the##name->name##des, F_GETFD)) == -1)   \
+            return errno;                                           \
+        flags |= FD_CLOEXEC;                                        \
+        if (fcntl(the##name->name##des, F_SETFD, flags) == -1)      \
+            return errno;                                           \
         the##name->flag &= ~APR_INHERIT;                            \
         apr_pool_child_cleanup_set(the##name->pool,                 \
                                    (void *)the##name,               \

Modified: apr/apr/trunk/network_io/unix/sockets.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/sockets.c?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/sockets.c (original)
+++ apr/apr/trunk/network_io/unix/sockets.c Fri Feb 27 01:34:54 2009
@@ -165,7 +165,16 @@
     set_socket_vars(*new, family, type, oprotocol);
 
 #ifndef HAVE_SOCK_CLOEXEC
-    APR_SET_FD_CLOEXEC((*new)->socketdes);
+    {
+        int flags;
+
+        if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
+            return errno;
+    }
 #endif
 
     (*new)->timeout = -1;
@@ -313,7 +322,16 @@
     }
 
 #ifndef HAVE_ACCEPT4
-    APR_SET_FD_CLOEXEC((*new)->socketdes);
+    {
+        int flags;
+
+        if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
+            return errno;
+    }
 #endif
 
     (*new)->inherit = 0;

Modified: apr/apr/trunk/poll/unix/epoll.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/epoll.c?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/epoll.c (original)
+++ apr/apr/trunk/poll/unix/epoll.c Fri Feb 27 01:34:54 2009
@@ -107,7 +107,16 @@
     }
 
 #ifndef HAVE_EPOLL_CREATE1
-    APR_SET_FD_CLOEXEC(fd);
+    {
+        int flags;
+
+        if ((flags = fcntl(fd, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(fd, F_SETFD, flags) == -1)
+            return errno;
+    }
 #endif
 
     pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t));
@@ -339,7 +348,16 @@
     }
 
 #ifndef HAVE_EPOLL_CREATE1
-    APR_SET_FD_CLOEXEC(fd);
+    {
+        int flags;
+
+        if ((flags = fcntl(fd, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(fd, F_SETFD, flags) == -1)
+            return errno;
+    }
 #endif
     
     pollcb->fd = fd;

Modified: apr/apr/trunk/poll/unix/kqueue.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/kqueue.c?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/kqueue.c (original)
+++ apr/apr/trunk/poll/unix/kqueue.c Fri Feb 27 01:34:54 2009
@@ -99,7 +99,16 @@
         return apr_get_netos_error();
     }
 
-    APR_SET_FD_CLOEXEC(pollset->p->kqueue_fd);
+    {
+        int flags;
+
+        if ((flags = fcntl(pollset->p->kqueue_fd, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(pollset->p->kqueue_fd, F_SETFD, flags) == -1)
+            return errno;
+    }
 
     pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
 
@@ -316,7 +325,16 @@
         return apr_get_netos_error();
     }
 
-    APR_SET_FD_CLOEXEC(fd);
+    {
+        int flags;
+
+        if ((flags = fcntl(fd, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(fd, F_SETFD, flags) == -1)
+            return errno;
+    }
  
     pollcb->fd = fd;
     pollcb->pollset.ke = (struct kevent *)apr_pcalloc(p, size * sizeof(struct kevent));

Modified: apr/apr/trunk/poll/unix/pollset.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/pollset.c?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/pollset.c (original)
+++ apr/apr/trunk/poll/unix/pollset.c Fri Feb 27 01:34:54 2009
@@ -89,8 +89,26 @@
     fd.desc_type = APR_POLL_FILE;
     fd.desc.f = pollset->wakeup_pipe[0];
 
-    APR_SET_FD_CLOEXEC(pollset->wakeup_pipe[0]->filedes);
-    APR_SET_FD_CLOEXEC(pollset->wakeup_pipe[1]->filedes);
+    {
+        int flags;
+
+        if ((flags = fcntl(pollset->wakeup_pipe[0]->filedes, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(pollset->wakeup_pipe[0]->filedes, F_SETFD, flags) == -1)
+            return errno;
+    }
+    {
+        int flags;
+
+        if ((flags = fcntl(pollset->wakeup_pipe[1]->filedes, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(pollset->wakeup_pipe[1]->filedes, F_SETFD, flags) == -1)
+            return errno;
+    }
 
     /* Add the pipe to the pollset
      */

Modified: apr/apr/trunk/poll/unix/port.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/port.c?rev=748371&r1=748370&r2=748371&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/port.c (original)
+++ apr/apr/trunk/poll/unix/port.c Fri Feb 27 01:34:54 2009
@@ -126,7 +126,16 @@
         return APR_ENOMEM;
     }
 
-    APR_SET_FD_CLOEXEC(pollset->p->port_fd);
+    {
+        int flags;
+
+        if ((flags = fcntl(pollset->p->port_fd, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(pollset->p->port_fd, F_SETFD, flags) == -1)
+            return errno;
+    }
 
     pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
 
@@ -398,7 +407,16 @@
         return apr_get_netos_error();
     }
 
-    APR_SET_FD_CLOEXEC(fd);
+    {
+        int flags;
+
+        if ((flags = fcntl(fd, F_GETFD)) == -1)
+            return errno;
+
+        flags |= FD_CLOEXEC;
+        if (fcntl(fd, F_SETFD, flags) == -1)
+            return errno;
+    }
 
     pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));
     apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);



Mime
View raw message