apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/network_io/unix sendrecv.c sockets.c sockopt.c
Date Fri, 30 May 2003 12:50:40 GMT
trawick     2003/05/30 05:50:40

  Modified:    .        CHANGES
               network_io/unix sendrecv.c sockets.c sockopt.c
  Log:
  Fix some problems with non-blocking socket handling on unix
  that resulted in infinite timeouts being used for non-blocking
  sockets with apr_socket_connect() and some read/write calls.
  
  Revision  Changes    Path
  1.412     +5 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.411
  retrieving revision 1.412
  diff -u -r1.411 -r1.412
  --- CHANGES	30 May 2003 12:15:11 -0000	1.411
  +++ CHANGES	30 May 2003 12:50:39 -0000	1.412
  @@ -1,5 +1,10 @@
   Changes with APR 0.9.4
   
  +  *) Fix some problems with non-blocking socket handling on unix
  +     that resulted in infinite timeouts being used for non-blocking
  +     sockets with apr_socket_connect() and some read/write calls.
  +     [Jeff Trawick]
  +
     *) Fix a bug in socket timeout handling on unix that left the
        socket non-blocking after disabling the timeout.
        [Jacob Craig Lewallen <jlewalle@cs.ucr.edu>]
  
  
  
  1.98      +18 -16    apr/network_io/unix/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- sendrecv.c	30 May 2003 12:28:44 -0000	1.97
  +++ sendrecv.c	30 May 2003 12:50:39 -0000	1.98
  @@ -80,7 +80,7 @@
       } while (rv == -1 && errno == EINTR);
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) 
  -        && sock->timeout != 0) {
  +        && apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
           apr_status_t arv;
   do_select:
           arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
  @@ -98,7 +98,7 @@
           *len = 0;
           return errno;
       }
  -    if (sock->timeout && rv < *len) {
  +    if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) && rv < *len) {
           sock->netmask |= APR_INCOMPLETE_WRITE;
       }
       (*len) = rv;
  @@ -120,7 +120,7 @@
       } while (rv == -1 && errno == EINTR);
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && 
  -      sock->timeout != 0) {
  +        apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
   do_select:
           arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
           if (arv != APR_SUCCESS) {
  @@ -137,7 +137,7 @@
           (*len) = 0;
           return errno;
       }
  -    if (sock->timeout && rv < *len) {
  +    if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) && rv < *len) {
           sock->netmask |= APR_INCOMPLETE_READ;
       }
       (*len) = rv;
  @@ -160,7 +160,7 @@
       } while (rv == -1 && errno == EINTR);
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
  -        && sock->timeout != 0) {
  +        && apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
           apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
           if (arv != APR_SUCCESS) {
               *len = 0;
  @@ -193,7 +193,7 @@
       } while (rv == -1 && errno == EINTR);
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
  -        sock->timeout != 0) {
  +        apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
           apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
           if (arv != APR_SUCCESS) {
               *len = 0;
  @@ -240,7 +240,7 @@
       } while (rv == -1 && errno == EINTR);
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && 
  -        sock->timeout != 0) {
  +        apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
           apr_status_t arv;
   do_select:
           arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
  @@ -258,7 +258,8 @@
           *len = 0;
           return errno;
       }
  -    if (sock->timeout && rv < requested_len) {
  +    if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) &&
  +        rv < requested_len) {
           sock->netmask |= APR_INCOMPLETE_WRITE;
       }
       (*len) = rv;
  @@ -339,7 +340,7 @@
   
       if (rv == -1 && 
           (errno == EAGAIN || errno == EWOULDBLOCK) && 
  -        sock->timeout > 0) {
  +        apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
   do_select:
           arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
           if (arv != APR_SUCCESS) {
  @@ -374,7 +375,7 @@
                * partial byte count;  this is a non-blocking socket.
                */
   
  -            if (sock->timeout) {
  +            if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
                   sock->netmask |= APR_INCOMPLETE_WRITE;
               }
               return arv;
  @@ -522,7 +523,7 @@
   
               if (rv == -1) {
                   if (errno == EAGAIN) {
  -                    if (sock->timeout) {
  +                    if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
                           sock->netmask |= APR_INCOMPLETE_WRITE;
                       }
                       /* FreeBSD's sendfile can return -1/EAGAIN even if it
  @@ -562,7 +563,7 @@
           }
           if (rv == -1 &&
               errno == EAGAIN && 
  -            sock->timeout > 0) {
  +            apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
               apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
               if (arv != APR_SUCCESS) {
                   *len = 0;
  @@ -680,7 +681,7 @@
   
       if (rc == -1 && 
           (errno == EAGAIN || errno == EWOULDBLOCK) && 
  -        sock->timeout > 0) {
  +        apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
           apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
   
           if (arv != APR_SUCCESS) {
  @@ -820,7 +821,7 @@
   
       if (rv == -1 &&
           (errno == EAGAIN || errno == EWOULDBLOCK) &&
  -        sock->timeout > 0) {
  +        apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
   do_select:
           arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
           if (arv != APR_SUCCESS) {
  @@ -848,7 +849,7 @@
           return errno;
       }
   
  -    if (sock->timeout &&
  +    if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) &&
           (parms.bytes_sent < (parms.file_bytes + parms.header_length + parms.trailer_length)))
{
           sock->netmask |= APR_INCOMPLETE_WRITE;
       }
  @@ -984,7 +985,8 @@
   
       /* Update how much we sent */
       *len = nbytes;
  -    if (sock->timeout && (*len < requested_len)) {
  +    if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) &&
  +        (*len < requested_len)) {
           sock->netmask |= APR_INCOMPLETE_WRITE;
       }
       return APR_SUCCESS;
  
  
  
  1.109     +2 -1      apr/network_io/unix/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- sockets.c	19 Mar 2003 05:03:24 -0000	1.108
  +++ sockets.c	30 May 2003 12:50:39 -0000	1.109
  @@ -271,7 +271,8 @@
       /* we can see EINPROGRESS the first time connect is called on a non-blocking
        * socket; if called again, we can see EALREADY
        */
  -    if (rc == -1 && (errno == EINPROGRESS || errno == EALREADY) && sock->timeout
!= 0) {
  +    if (rc == -1 && (errno == EINPROGRESS || errno == EALREADY) &&
  +        apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
           rc = apr_wait_for_io_or_timeout(NULL, sock, 0);
           if (rc != APR_SUCCESS) {
               return rc;
  
  
  
  1.70      +4 -4      apr/network_io/unix/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- sockopt.c	30 May 2003 12:15:12 -0000	1.69
  +++ sockopt.c	30 May 2003 12:50:40 -0000	1.70
  @@ -137,14 +137,14 @@
               apr_set_option(&sock->netmask, APR_SO_NONBLOCK, 0);
           } 
       }
  -    /* must disable the incomplete read support if we change to a
  -     * blocking socket.
  +    /* must disable the incomplete read support if we disable
  +     * a timeout
        */
  -    if (t == 0) {
  +    if (t <= 0) {
           sock->netmask &= ~APR_INCOMPLETE_READ;
       }
       sock->timeout = t; 
  -    apr_set_option(&sock->netmask, APR_SO_TIMEOUT, t);
  +    apr_set_option(&sock->netmask, APR_SO_TIMEOUT, t > 0);
       return APR_SUCCESS;
   }
   
  
  
  

Mime
View raw message