apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: apr/network_io/unix sockopt.c sendrecv.c
Date Mon, 30 Jul 2001 17:56:17 GMT
stoddard    01/07/30 10:56:17

  Modified:    .        CHANGES
               include  apr_network_io.h
               network_io/unix sockopt.c sendrecv.c
  Log:
  Performance: Add new socket option, APR_INCOMPLETE_READ, that should be
  set when you expect the first non-blocking read to fail with
  EAGAIN. Setting APR_INCOMPLETE_READ prior to calling apr_read
  will cause select() to be called first to wait for bytes
  to read. [Brian Pane, Dean Gaudet]
  
  Reviewed by:	Bill Stoddard
  
  Revision  Changes    Path
  1.129     +6 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.128
  retrieving revision 1.129
  diff -u -r1.128 -r1.129
  --- CHANGES	2001/07/26 00:08:40	1.128
  +++ CHANGES	2001/07/30 17:56:16	1.129
  @@ -1,5 +1,11 @@
   Changes with APR b1  
   
  +  *) Add new socket option, APR_INCOMPLETE_READ, that should be
  +     set when you expect the first non-blocking read to fail with
  +     EAGAIN. Setting APR_INCOMPLETE_READ prior to calling apr_read
  +     will cause select() to be called first to wait for bytes
  +     to read. [Brian Pane, Dean Gaudet]
  +
     *) Better installation.  This makes us install the APRVARS file,
        as well as MM.  [Ryan Bloom]
   
  
  
  
  1.108     +11 -0     apr/include/apr_network_io.h
  
  Index: apr_network_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_network_io.h,v
  retrieving revision 1.107
  retrieving revision 1.108
  diff -u -r1.107 -r1.108
  --- apr_network_io.h	2001/07/26 15:39:25	1.107
  +++ apr_network_io.h	2001/07/30 17:56:16	1.108
  @@ -103,6 +103,17 @@
                                      * APR_TCP_NODELAY should be turned on
                                      * again when NOPUSH is turned off
                                      */
  +#define APR_INCOMPLETE_READ 4096  /* Set on non-blocking sockets
  +				   * (APR_SO_TIMEOUT != 0) on which the
  +				   * previous read() did not fill a buffer
  +				   * completely.  the next apr_recv() will
  +				   * first call select()/poll() rather than
  +				   * going straight into read().  (Can also
  +				   * be set by an application to force a
  +				   * select()/poll() call before the next
  +				   * read, in cases where the app expects
  +				   * that an immediate read would fail.)
  +				   */
   
   #define APR_POLLIN    0x001 
   #define APR_POLLPRI   0x002
  
  
  
  1.48      +9 -0      apr/network_io/unix/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- sockopt.c	2001/07/25 18:01:01	1.47
  +++ sockopt.c	2001/07/30 17:56:16	1.48
  @@ -203,6 +203,12 @@
                   }
               } 
           }
  +	/* must disable the incomplete read support if we change to a
  +	 * blocking socket.
  +	 */
  +	if (on == 0) {
  +	    sock->netmask &= ~APR_INCOMPLETE_READ;
  +	}
           sock->timeout = on; 
           apr_set_option(&sock->netmask, APR_SO_TIMEOUT, on);
       } 
  @@ -265,6 +271,9 @@
   #else
           return APR_ENOTIMPL;
   #endif
  +    }
  +    if (opt & APR_INCOMPLETE_READ) {
  +	apr_set_option(&sock->netmask, APR_INCOMPLETE_READ, on);
       }
   
       return APR_SUCCESS; 
  
  
  
  1.75      +12 -2     apr/network_io/unix/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- sendrecv.c	2001/07/26 17:11:04	1.74
  +++ sendrecv.c	2001/07/30 17:56:16	1.75
  @@ -125,14 +125,21 @@
   apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
   {
       ssize_t rv;
  -    
  +    apr_status_t arv;
  +
  +    if (sock->netmask & APR_INCOMPLETE_READ) {
  +	sock->netmask &= ~APR_INCOMPLETE_READ;
  +    	goto do_select;
  +    }
  +
       do {
           rv = read(sock->socketdes, buf, (*len));
       } while (rv == -1 && errno == EINTR);
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && 
         sock->timeout != 0) {
  -        apr_status_t arv = apr_wait_for_io_or_timeout(sock, 1);
  +do_select:
  +	arv = apr_wait_for_io_or_timeout(sock, 1);
           if (arv != APR_SUCCESS) {
               *len = 0;
               return arv;
  @@ -146,6 +153,9 @@
       if (rv == -1) {
           (*len) = 0;
           return errno;
  +    }
  +    if (sock->timeout && rv < *len) {
  +	sock->netmask |= APR_INCOMPLETE_READ;
       }
       (*len) = rv;
       if (rv == 0) {
  
  
  

Mime
View raw message