apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grega...@apache.org
Subject cvs commit: apr/network_io/unix sendrecv.c
Date Thu, 26 Jul 2001 14:58:37 GMT
gregames    01/07/26 07:58:37

  Modified:    network_io/unix sendrecv.c
  Log:
  tweak FreeBSD's apr_sendfile to shrink the object code size.
  
  This is what is running on daedalus now (minus the trap for our
  once-every-three-days-or-so core dump).
  
  Revision  Changes    Path
  1.73      +12 -46    apr/network_io/unix/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- sendrecv.c	2001/07/25 20:59:29	1.72
  +++ sendrecv.c	2001/07/26 14:58:37	1.73
  @@ -430,7 +430,12 @@
               if (rv == -1 && errno == EAGAIN && nbytes) {
                   rv = 0;
               }
  -        }
  +            
  +            /* ??? performance: if rv == 0 is the most common case, 
  +             *     we may want to return here and avoid a potential 
  +             *     i-cache miss.
  +             */
  +        }    
           else {
               /* just trailer bytes... use writev()
                */
  @@ -445,55 +450,16 @@
                   nbytes = 0;
               }
           }
  -    } while (rv == -1 && errno == EINTR);
  -
       if (rv == -1 &&
           errno == EAGAIN && 
           sock->timeout > 0) {
  -        apr_status_t arv = apr_wait_for_io_or_timeout(sock, 0);
  -        if (arv != APR_SUCCESS) {
  -            *len = 0;
  -            return arv;
  -        }
  -        else {
  -            do {
  -                if (bytes_to_send) {
  -                    /* We won't dare call sendfile() if we don't have
  -                     * header or file bytes to send because bytes_to_send == 0
  -                     * means send the whole file.
  -                     */
  -                    rv = sendfile(file->filedes, /* file to be sent */
  -                                  sock->socketdes, /* socket */
  -                                  *offset,       /* where in the file to start */
  -                                  bytes_to_send, /* number of bytes to send */
  -                                  &headerstruct, /* Headers/footers */
  -                                  &nbytes,       /* number of bytes written */
  -                                  flags);        /* undefined, set to 0 */
  -                    /* FreeBSD's sendfile can return -1/EAGAIN even if it
  -                     * sent bytes.  Sanitize the result so we get normal EAGAIN
  -                     * semantics w.r.t. bytes sent.
  -                     */
  -                    if (rv == -1 && errno == EAGAIN && nbytes) {
  -                        rv = 0;
  -                    }
  -                }
  -                else {
  -                    /* just trailer bytes... use writev()
  -                     */
  -                    rv = writev(sock->socketdes,
  -                                hdtr->trailers,
  -                                hdtr->numtrailers);
  -                    if (rv > 0) {
  -                        nbytes = rv;
  -                        rv = 0;
  -                    }
  -                    else {
  -                        nbytes = 0;
  -                    }
  -                }
  -            } while (rv == -1 && errno == EINTR);
  +            apr_status_t arv = apr_wait_for_io_or_timeout(sock, 0);
  +            if (arv != APR_SUCCESS) {
  +                *len = 0;
  +                return arv;
  +            }
           }
  -    }
  +    } while (rv == -1 && (errno == EINTR || errno == EAGAIN));
   
       (*len) = nbytes;
       if (rv == -1) {
  
  
  

Mime
View raw message