apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r1449570 - in /apr/apr/branches/1.4.x: ./ CHANGES build/apr_network.m4
Date Mon, 25 Feb 2013 00:16:02 GMT
Author: rjung
Date: Mon Feb 25 00:16:02 2013
New Revision: 1449570

URL: http://svn.apache.org/r1449570
Log:
Fix detection of O_NONBLOCK inheritance.

The original test failed occasionally on a busy
FreeBSD server when accept() returned EAGAIN.

Backport of r1449568 from trunk resp. r1449569
from 1.5.x.

Modified:
    apr/apr/branches/1.4.x/   (props changed)
    apr/apr/branches/1.4.x/CHANGES
    apr/apr/branches/1.4.x/build/apr_network.m4

Propchange: apr/apr/branches/1.4.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1449568

Modified: apr/apr/branches/1.4.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/CHANGES?rev=1449570&r1=1449569&r2=1449570&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.4.x/CHANGES [utf-8] Mon Feb 25 00:16:02 2013
@@ -1,6 +1,9 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.4.7
 
+  *) configure: Fix detection of O_NONBLOCK inheritance on busy
+     systems.  [Rainer Jung]
+
   *) Remove unused code, fix strict C compliance bug in SHA-256
      implementation.  [Jan Kaluza <jkaluza redhat.com>]
 

Modified: apr/apr/branches/1.4.x/build/apr_network.m4
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/build/apr_network.m4?rev=1449570&r1=1449569&r2=1449570&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/build/apr_network.m4 (original)
+++ apr/apr/branches/1.4.x/build/apr_network.m4 Mon Feb 25 00:16:02 2013
@@ -555,13 +555,24 @@ dnl
 AC_DEFUN([APR_CHECK_O_NONBLOCK_INHERITED], [
   AC_CACHE_CHECK(if O_NONBLOCK setting is inherited from listening sockets, ac_cv_o_nonblock_inherited,[
   AC_TRY_RUN( [
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
@@ -632,6 +643,26 @@ int main(void) {
         exit(1);
     }
     sa_len = sizeof sa;
+    /* 1 second select timeout */
+    tv.tv_sec = 1;
+    tv.tv_usec = 0;
+    /* Set up fd set */
+    FD_ZERO(&fds);
+    FD_SET(listen_s, &fds);
+    /* Wait for socket to become readable */
+    rc = select(listen_s + 1, &fds, NULL, NULL, &tv);
+    if (rc < 0) {
+        perror("select");
+        exit(1);
+    }
+    if (rc == 0) {
+        fprintf(stderr, "Socket failed to become readable (timeout)\n");
+        exit(1);
+    }
+    if (!FD_ISSET(listen_s, &fds)) {
+        fprintf(stderr, "Socket failed to become readable (selected another fd)\n");
+        exit(1);
+    }
     connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len);
     if (connected_s < 0) {
         perror("accept");



Mime
View raw message