You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dr...@locus.apache.org on 2000/10/11 19:02:02 UTC

cvs commit: apache-2.0/src/lib/apr/network_io/unix sendrecv.c

dreid       00/10/11 10:02:00

  Modified:    src/lib/apr/network_io/unix sendrecv.c
  Log:
  Tidy up some network code.  The only BeOS version that sees this code is
  BONE and that uses read/write so remove the defines as they're not needed
  and this makes the code easier to read.  Also replace some tabs with spaces
  and move some line breaks to hopefully make it easier to read.
  
  Revision  Changes    Path
  1.41      +24 -37    apache-2.0/src/lib/apr/network_io/unix/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sendrecv.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- sendrecv.c	2000/09/22 11:37:07	1.40
  +++ sendrecv.c	2000/10/11 17:01:59	1.41
  @@ -54,17 +54,6 @@
   
   #include "networkio.h"
   
  -/* BeOS needs to use send/recv for socket I/O, this allows us to do that
  - * with minimal changes in the code.
  - */
  -#ifdef BEOS
  -#define WRITE(x,y,z)  send(x,y,z,0)
  -#define READ(x,y,z)   recv(x,y,z,0)
  -#else
  -#define WRITE(x,y,z)  write(x,y,z)
  -#define READ(x,y,z)   read(x,y,z)
  -#endif
  -
   #if APR_HAS_SENDFILE
   /* This file is needed to allow us access to the apr_file_t internals. */
   #include "../../file_io/unix/fileio.h"
  @@ -117,11 +106,11 @@
       ssize_t rv;
       
       do {
  -        rv = WRITE(sock->socketdes, buf, (*len));
  +        rv = write(sock->socketdes, buf, (*len));
       } while (rv == -1 && errno == EINTR);
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) 
  -        && sock->timeout != 0) {
  +      && sock->timeout != 0) {
           apr_status_t arv = wait_for_io_or_timeout(sock, 0);
           if (arv != APR_SUCCESS) {
               *len = 0;
  @@ -129,13 +118,13 @@
           }
           else {
               do {
  -                rv = WRITE(sock->socketdes, buf, (*len));
  +                rv = write(sock->socketdes, buf, (*len));
               } while (rv == -1 && errno == EINTR);
           }
       }
       if (rv == -1) {
  -	*len = 0;
  -	return errno;
  +        *len = 0;
  +        return errno;
       }
       (*len) = rv;
       return APR_SUCCESS;
  @@ -146,20 +135,19 @@
       ssize_t rv;
       
       do {
  -        rv = READ(sock->socketdes, buf, (*len));
  +        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 = wait_for_io_or_timeout(sock, 1);
  -	if (arv != APR_SUCCESS) {
  -	    *len = 0;
  -	    return arv;
  -	}
  +    if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && 
  +      sock->timeout != 0) {
  +        apr_status_t arv = wait_for_io_or_timeout(sock, 1);
  +        if (arv != APR_SUCCESS) {
  +            *len = 0;
  +            return arv;
  +        }
           else {
               do {
  -                rv = READ(sock->socketdes, buf, (*len));
  +                rv = read(sock->socketdes, buf, (*len));
               } while (rv == -1 && errno == EINTR);
           }
       }
  @@ -181,23 +169,22 @@
           rv = writev(sock->socketdes, vec, nvec);
       } while (rv == -1 && errno == EINTR);
   
  -    if (rv == -1 && 
  -        (errno == EAGAIN || errno == EWOULDBLOCK) && 
  -        sock->timeout != 0) {
  -	apr_status_t arv = wait_for_io_or_timeout(sock, 0);
  -	if (arv != APR_SUCCESS) {
  -	    *len = 0;
  -	    return arv;
  -	}
  +    if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && 
  +      sock->timeout != 0) {
  +        apr_status_t arv = wait_for_io_or_timeout(sock, 0);
  +        if (arv != APR_SUCCESS) {
  +            *len = 0;
  +            return arv;
  +        }
           else {
               do {
  -        	rv = writev(sock->socketdes, vec, nvec);
  +                rv = writev(sock->socketdes, vec, nvec);
               } while (rv == -1 && errno == EINTR);
           }
       }
       if (rv == -1) {
  -	*len = 0;
  -	return errno;
  +        *len = 0;
  +        return errno;
       }
       (*len) = rv;
       return APR_SUCCESS;