diff options
author | rjung <rjung@13f79535-47bb-0310-9956-ffa450edef68> | 2013-02-25 00:11:37 +0000 |
---|---|---|
committer | rjung <rjung@13f79535-47bb-0310-9956-ffa450edef68> | 2013-02-25 00:11:37 +0000 |
commit | 14ba8e1b2e1a3a9be1b5cd03497cdd4a5801b1c8 (patch) | |
tree | f93e6dce403d5a5f1104088336b430e6065b3e5f /build | |
parent | 628bd09d6fd98b1d2e13415af17004b4b9902449 (diff) | |
download | libapr-14ba8e1b2e1a3a9be1b5cd03497cdd4a5801b1c8.tar.gz |
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.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1449569 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'build')
-rw-r--r-- | build/apr_network.m4 | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/build/apr_network.m4 b/build/apr_network.m4 index 4d479a45a..d70fbd998 100644 --- a/build/apr_network.m4 +++ b/build/apr_network.m4 @@ -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"); |