apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: apr/build apr_network.m4
Date Mon, 15 Apr 2002 05:55:24 GMT
brianp      02/04/14 22:55:24

  Modified:    .        configure.in
               include  apr.h.in
               build    apr_network.m4
  Log:
  Added a test to determine whether the O_NONBLOCK socket flag
  is inherited across an accept(2).  (Solaris 8, at least, has
  this property.)
  
  Revision  Changes    Path
  1.429     +2 -0      apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apr/configure.in,v
  retrieving revision 1.428
  retrieving revision 1.429
  diff -u -r1.428 -r1.429
  --- configure.in	12 Apr 2002 01:19:44 -0000	1.428
  +++ configure.in	15 Apr 2002 05:55:24 -0000	1.429
  @@ -809,6 +809,7 @@
   AC_SUBST(fork)
   AC_SUBST(have_inet_addr)
   AC_SUBST(tcp_nodelay_inherited)
  +AC_SUBST(o_nonblock_inherited)
   AC_SUBST(have_inet_network)
   AC_SUBST(have_sigaction)
   AC_SUBST(have_setrlimit)
  @@ -1532,6 +1533,7 @@
   fi
   
   APR_CHECK_TCP_NODELAY_INHERITED
  +APR_CHECK_O_NONBLOCK_INHERITED
   
   dnl # Look for a way of corking TCP...
   APR_CHECK_DEFINE(TCP_CORK, netinet/tcp.h)
  
  
  
  1.107     +4 -0      apr/include/apr.h.in
  
  Index: apr.h.in
  ===================================================================
  RCS file: /home/cvs/apr/include/apr.h.in,v
  retrieving revision 1.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- apr.h.in	11 Apr 2002 04:36:54 -0000	1.106
  +++ apr.h.in	15 Apr 2002 05:55:24 -0000	1.107
  @@ -172,6 +172,10 @@
   */
   #define APR_TCP_NODELAY_INHERITED @tcp_nodelay_inherited@
   
  +/* Is the O_NONBLOCK flag inherited from listening sockets?
  +*/
  +#define APR_O_NONBLOCK_INHERITED @o_nonblock_inherited@
  +
   /* Typedefs that APR needs. */
   
   typedef  unsigned char           apr_byte_t;
  
  
  
  1.16      +113 -0    apr/build/apr_network.m4
  
  Index: apr_network.m4
  ===================================================================
  RCS file: /home/cvs/apr/build/apr_network.m4,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- apr_network.m4	24 Mar 2002 16:01:33 -0000	1.15
  +++ apr_network.m4	15 Apr 2002 05:55:24 -0000	1.16
  @@ -395,6 +395,119 @@
   fi
   ])
   
  +dnl
  +dnl see if O_NONBLOCK setting is inherited from listening sockets
  +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( [
  +#include <stdio.h>
  +#ifdef HAVE_SYS_TYPES_H
  +#include <sys/types.h>
  +#endif
  +#ifdef HAVE_SYS_SOCKET_H
  +#include <sys/socket.h>
  +#endif
  +#ifdef HAVE_NETINET_IN_H
  +#include <netinet/in.h>
  +#endif
  +#ifdef HAVE_NETINET_TCP_H
  +#include <netinet/tcp.h>
  +#endif
  +#ifndef HAVE_SOCKLEN_T
  +typedef int socklen_t;
  +#endif
  +#ifdef HAVE_FCNTL_H
  +#include <fcntl.h>
  +#endif
  +int main(void) {
  +    int listen_s, connected_s, client_s;
  +    int listen_port, rc;
  +    struct sockaddr_in sa;
  +    socklen_t sa_len;
  +
  +    listen_s = socket(AF_INET, SOCK_STREAM, 0);
  +    if (listen_s < 0) {
  +        perror("socket");
  +        exit(1);
  +    }
  +    memset(&sa, 0, sizeof sa);
  +    sa.sin_family = AF_INET;
  +#ifdef BEOS
  +    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  +#endif
  +    /* leave port 0 to get ephemeral */
  +    rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa);
  +    if (rc < 0) {
  +        perror("bind for ephemeral port");
  +        exit(1);
  +    }
  +    /* find ephemeral port */
  +    sa_len = sizeof(sa);
  +    rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len);
  +    if (rc < 0) {
  +        perror("getsockname");
  +        exit(1);
  +    }
  +    listen_port = sa.sin_port;
  +    rc = listen(listen_s, 5);
  +    if (rc < 0) {
  +        perror("listen");
  +        exit(1);
  +    }
  +    rc = fcntl(listen_s, F_SETFL, O_NONBLOCK);
  +    if (rc < 0) {
  +        perror("fcntl(F_SETFL)");
  +        exit(1);
  +    }
  +    client_s = socket(AF_INET, SOCK_STREAM, 0);
  +    if (client_s < 0) {
  +        perror("socket");
  +        exit(1);
  +    }
  +    memset(&sa, 0, sizeof sa);
  +    sa.sin_family = AF_INET;
  +    sa.sin_port   = listen_port;
  +#ifdef BEOS
  +    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  +#endif
  +    /* leave sin_addr all zeros to use loopback */
  +    rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa);
  +    if (rc < 0) {
  +        perror("connect");
  +        exit(1);
  +    }
  +    sa_len = sizeof sa;
  +    connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len);
  +    if (connected_s < 0) {
  +        perror("accept");
  +        exit(1);
  +    }
  +    rc = fcntl(connected_s, F_GETFL, 0);
  +    if (rc < 0) {
  +        perror("fcntl(F_GETFL)");
  +        exit(1);
  +    }
  +    if (!(rc & O_NONBLOCK)) {
  +        fprintf(stderr, "O_NONBLOCK is not set in the child.\n");
  +        exit(1);
  +    }
  +    return 0;
  +}
  +],[
  +    ac_cv_o_nonblock_inherited="yes"
  +],[
  +    ac_cv_o_nonblock_inherited="no"
  +],[
  +    ac_cv_o_nonblock_inherited="yes"
  +])])
  +if test "$ac_cv_o_nonblock_inherited" = "yes"; then
  +    o_nonblock_inherited=1
  +else
  +    o_nonblock_inherited=0
  +fi
  +])
  +
   dnl 
   dnl check for socklen_t, fall back to unsigned int
   dnl
  
  
  

Mime
View raw message