apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/network_io/unix sendrecv.c
Date Thu, 04 Jan 2001 22:02:37 GMT
dreid       01/01/04 14:02:36

  Modified:    .        acconfig.h configure.in
               include  apr.h.in
               network_io/unix sendrecv.c
  Log:
  This patch adds support for TCP_NOPUSH to APR.  Basically we look for
  TCP_CORK or TCP_NOPUSH and if we find them we define APR_HAVE_CORKABLE_TCP.
  Once defined we then make os_cork and os_uncork available.  At present
  they're not used except in the apr_sendfile code, but there may be uses
  for the routines in other areas of our network code as well, hence the change.
  
  In addition I've changed SOL_TCP to IPPROTO_TCP as this is more portable.
  
  Also tiny change to the way we check the version number in configure.in to
  decide if we want to use sendfile on FreeBSD.
  
  Submitted by:   Tony Finch <dot@dotat.at>
  
  Revision  Changes    Path
  1.37      +4 -0      apr/acconfig.h
  
  Index: acconfig.h
  ===================================================================
  RCS file: /home/cvs/apr/acconfig.h,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- acconfig.h	2000/12/01 21:33:57	1.36
  +++ acconfig.h	2001/01/04 22:02:24	1.37
  @@ -37,6 +37,10 @@
   /* BeOS specific flag */
   #undef HAVE_BONE_VERSION
   
  +/* Does this system have a corkable TCP? */
  +#undef HAVE_TCP_CORK
  +#undef HAVE_TCP_NOPUSH
  +
   @BOTTOM@
   
   /* Make sure we have ssize_t defined to be something */
  
  
  
  1.200     +16 -1     apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apr/configure.in,v
  retrieving revision 1.199
  retrieving revision 1.200
  diff -u -r1.199 -r1.200
  --- configure.in	2001/01/03 20:08:43	1.199
  +++ configure.in	2001/01/04 22:02:26	1.200
  @@ -588,7 +588,7 @@
   orig_sendfile=$sendfile
   case "$OS" in
       *freebsd*)
  -        if test `echo "$OS" | sed -e 's/.*\(.\)\.\(.\)/\1\2/'` -le "41"; then
  +        if test `uname -r | sed -e 's/\(.\)\.\(.\)\..*/\1\2/'` -le "41"; then
               if test "$threads" = "1"; then
                   sendfile="0"
               fi
  @@ -787,6 +787,21 @@
   APR_CHECK_SOCKADDR_SA_LEN
   
   APR_CHECK_GETHOSTBYNAME_NAS
  +
  +dnl # Look for a way of corking TCP...
  +AC_CHECK_DEFINE(TCP_CORK, netinet/tcp.h)
  +AC_CHECK_DEFINE(TCP_NOPUSH, netinet/tcp.h)
  +apr_tcp_nopush_flag="0"
  +if test "x$ac_cv_define_TCP_CORK" = "xyes"; then
  +    apr_tcp_nopush_flag="TCP_CORK"
  +    have_corkable_tcp="1"
  +fi
  +if test "x$ac_cv_define_TCP_NOPUSH" = "xyes"; then
  +    apr_tcp_nopush_flag="TCP_NOPUSH"
  +    have_corkable_tcp="1"
  +fi
  +AC_SUBST(apr_tcp_nopush_flag)
  +AC_SUBST(have_corkable_tcp)
   
   echo $ac_n "${nl}Checking for IPv6 Networking support...${nl}"
   dnl # Start of checking for IPv6 support...
  
  
  
  1.61      +6 -1      apr/include/apr.h.in
  
  Index: apr.h.in
  ===================================================================
  RCS file: /home/cvs/apr/include/apr.h.in,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- apr.h.in	2000/12/22 16:54:50	1.60
  +++ apr.h.in	2001/01/04 22:02:31	1.61
  @@ -86,8 +86,8 @@
   #define APR_HAVE_MEMMOVE        @have_memmove@
   #define APR_HAVE_BZERO          @have_bzero@
   #define APR_HAVE_IPV6           @have_ipv6@
  +#define APR_HAVE_CORKABLE_TCP   @have_corkable_tcp@ 
   
  -
   #if APR_HAVE_SYS_TYPES_H
   #include <sys/types.h>
   #endif
  @@ -127,6 +127,11 @@
   /* This macro indicates whether or not EBCDIC is the native character set.
    */
   #define APR_CHARSET_EBCDIC        @apr_charset_ebcdic@
  +
  +/* If we have a TCP implementation that can be "corked", what flag
  + * do we use?
  + */
  +#define APR_TCP_NOPUSH_FLAG       @apr_tcp_nopush_flag@
   
   /* Typedefs that APR needs. */
   
  
  
  
  1.55      +25 -19    apr/network_io/unix/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- sendrecv.c	2001/01/02 01:12:17	1.54
  +++ sendrecv.c	2001/01/04 22:02:34	1.55
  @@ -194,35 +194,28 @@
   }
   #endif
   
  -#if APR_HAS_SENDFILE
  -
  - /* TODO: Verify that all platforms handle the fd the same way 
  -  *     (i.e. not moving current file pointer)
  -  *     - Should flags be an int_32 or what?
  -  */
  +/* XXX - if we start using these elsewhere in this file we'll
  + * need to move these to the top...
  + */
   
  -static apr_hdtr_t no_hdtr; /* used below when caller passes NULL for apr_hdtr_t */
  +#if APR_HAVE_CORKABLE_TCP
   
  -#if defined(__linux__) && defined(HAVE_WRITEV)
  -
  -/* TCP_CORK keeps us from sending partial frames when we shouldn't 
  - * however, it is mutually exclusive w/TCP_NODELAY  
  +/* TCP_CORK & TCP_NOPUSH keep us from sending partial frames when we
  + * shouldn't. They are however, mutually exclusive with TCP_NODELAY  
    */
   
   static int os_cork(apr_socket_t *sock)
   {
  -    /* Linux only for now */
  -
       int nodelay_off = 0, corkflag = 1, rv, delayflag;
       apr_socklen_t delaylen = sizeof(delayflag);
   
       /* XXX it would be cheaper to use an apr_socket_t flag here */
  -    rv = getsockopt(sock->socketdes, SOL_TCP, TCP_NODELAY,
  +    rv = getsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY,
                       (void *) &delayflag, &delaylen);
       if (rv == 0) {  
           if (delayflag != 0) {
               /* turn off nodelay temporarily to allow cork */
  -            rv = setsockopt(sock->socketdes, SOL_TCP, TCP_NODELAY,
  +            rv = setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY,
                               (const void *) &nodelay_off, sizeof(nodelay_off));
               /* XXX nuke the rv checking once this is proven solid */
               if (rv < 0) {
  @@ -230,25 +223,38 @@
               }   
           } 
       }
  -    rv = setsockopt(sock->socketdes, SOL_TCP, TCP_CORK,
  +    rv = setsockopt(sock->socketdes, IPPROTO_TCP, APR_TCP_NOPUSH_FLAG,
                       (const void *) &corkflag, sizeof(corkflag));
       return rv == 0 ? delayflag : rv;
   }   
   
   static int os_uncork(apr_socket_t *sock, int delayflag)
   {
  -    /* Uncork to send queued frames - Linux only for now */
  +    /* Uncork to send queued frames */
       
       int corkflag = 0, rv;
  -    rv = setsockopt(sock->socketdes, SOL_TCP, TCP_CORK,
  +    rv = setsockopt(sock->socketdes, IPPROTO_TCP, APR_TCP_NOPUSH_FLAG,
                       (const void *) &corkflag, sizeof(corkflag));
       if (rv == 0) {
           /* restore TCP_NODELAY to its original setting */
  -        rv = setsockopt(sock->socketdes, SOL_TCP, TCP_NODELAY,
  +        rv = setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY,
                           (const void *) &delayflag, sizeof(delayflag));
       }
       return rv;
   }
  +#endif /* APR_HAVE_CORKABLE_TCP */
  +
  +#if APR_HAS_SENDFILE
  +
  +/* TODO: Verify that all platforms handle the fd the same way,
  + * i.e. that they don't move the file pointer.
  + */
  +/* TODO: what should flags be?  int_32? */
  +
  +/* Define a structure to pass in when we have a NULL header value */
  +static apr_hdtr_t no_hdtr;
  +
  +#if defined(__linux__) && defined(HAVE_WRITEV)
   
   apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
           		apr_hdtr_t *hdtr, apr_off_t *offset, apr_size_t *len,
  
  
  

Mime
View raw message