From commits-return-12777-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Mon Feb 25 00:11:00 2013 Return-Path: X-Original-To: apmail-apr-commits-archive@www.apache.org Delivered-To: apmail-apr-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EB028E865 for ; Mon, 25 Feb 2013 00:10:59 +0000 (UTC) Received: (qmail 65257 invoked by uid 500); 25 Feb 2013 00:10:59 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 65137 invoked by uid 500); 25 Feb 2013 00:10:59 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 65116 invoked by uid 99); 25 Feb 2013 00:10:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Feb 2013 00:10:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Feb 2013 00:10:48 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3A9F123888CD; Mon, 25 Feb 2013 00:10:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1449568 - /apr/apr/trunk/build/apr_network.m4 Date: Mon, 25 Feb 2013 00:10:29 -0000 To: commits@apr.apache.org From: rjung@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130225001029.3A9F123888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rjung Date: Mon Feb 25 00:10:28 2013 New Revision: 1449568 URL: http://svn.apache.org/r1449568 Log: Fix detection of O_NONBLOCK inheritance. The original test failed occasionally on a busy FreeBSD server when accept() returned EAGAIN. Modified: apr/apr/trunk/build/apr_network.m4 Modified: apr/apr/trunk/build/apr_network.m4 URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/apr_network.m4?rev=1449568&r1=1449567&r2=1449568&view=diff ============================================================================== --- apr/apr/trunk/build/apr_network.m4 (original) +++ apr/apr/trunk/build/apr_network.m4 Mon Feb 25 00:10:28 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 +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_STDIO_H #include +#endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif #ifdef HAVE_NETINET_IN_H #include #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");