apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1551672 - in /apr/apr/branches/1.5.x: ./ CHANGES network_io/unix/sockets.c
Date Tue, 17 Dec 2013 19:55:34 GMT
Author: trawick
Date: Tue Dec 17 19:55:34 2013
New Revision: 1551672

URL: http://svn.apache.org/r1551672
Log:
merge r1551659 from trunk:

Fix the inheritance of the non-blocking option across apr_socket_accept()
on FreeBSD 10 which was introduced with APR 1.5.0 through an unlikely
mechanism:

* FreeBSD 10 introduced accept4().  APR uses accept4() where it can find it.
  accept4() on Linux and FreeBSD 10 both have a SOCK_NONBLOCK flag, but on
  FreeBSD 10 the SOCK_NONBLOCK is the sole determiner of whether or not the
  connected socket is non-blocking.
* clang is normally used on FreeBSD 10.
* APR's configure-time check for inherited O_NONBLOCK didn't work with clang,
  so initially the lack of inheritance across accept4() wasn't a problem.
* APR 1.5.0 allowed the configure-time check to work with clang, exposing
  the bad expectation about accept4() matching the accept() behavior.

With FreeBSD accept4() (avail in 10+), O_NONBLOCK is not inherited
(unlike Linux).  Mimic the accept() behavior here in a way that
may help other platforms as well.

Modified:
    apr/apr/branches/1.5.x/   (props changed)
    apr/apr/branches/1.5.x/CHANGES
    apr/apr/branches/1.5.x/network_io/unix/sockets.c

Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1551659

Modified: apr/apr/branches/1.5.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/CHANGES?rev=1551672&r1=1551671&r2=1551672&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.5.x/CHANGES [utf-8] Tue Dec 17 19:55:34 2013
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.5.1
 
+  *) FreeBSD 10: Correct a regression in 1.5.0 which affected non-
+     blocking sockets in some applications, including httpd.  [Jeff
+     Trawick]
+
   *) Windows cmake build: Fix incorrect installation of some .pdb
      files.  [Jeff Trawick]
 

Modified: apr/apr/branches/1.5.x/network_io/unix/sockets.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/network_io/unix/sockets.c?rev=1551672&r1=1551671&r2=1551672&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/network_io/unix/sockets.c (original)
+++ apr/apr/branches/1.5.x/network_io/unix/sockets.c Tue Dec 17 19:55:34 2013
@@ -207,7 +207,20 @@ apr_status_t apr_socket_accept(apr_socke
     sa.salen = sizeof(sa.sa);
 
 #ifdef HAVE_ACCEPT4
-    s = accept4(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen, SOCK_CLOEXEC);
+    {
+        int flags = SOCK_CLOEXEC;
+
+#if defined(SOCK_NONBLOCK) && APR_O_NONBLOCK_INHERITED
+        /* With FreeBSD accept4() (avail in 10+), O_NONBLOCK is not inherited
+         * (unlike Linux).  Mimic the accept() behavior here in a way that
+         * may help other platforms.
+         */
+        if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) {
+            flags |= SOCK_NONBLOCK;
+        }
+#endif
+        s = accept4(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen, flags);
+    }
 #else
     s = accept(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen);
 #endif



Mime
View raw message