httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_core.c
Date Sat, 07 Oct 2000 21:54:17 GMT
rbb         00/10/07 14:54:17

  Modified:    src      CHANGES
               src/lib/apr/include apr_network_io.h
               src/main http_core.c
  Log:
  Update send_the_file to fall back to a read/write loop on platforms
  without sendfile.  This also makes the apr_hdtr_t type available on
  all platforms, regardless of whether apr_sendfile is defined or not.
  Submitted by:	Brian Havard and Ryan Bloom
  
  Revision  Changes    Path
  1.258     +4 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.257
  retrieving revision 1.258
  diff -u -r1.257 -r1.258
  --- CHANGES	2000/10/07 19:54:22	1.257
  +++ CHANGES	2000/10/07 21:54:11	1.258
  @@ -1,4 +1,8 @@
   Changes with Apache 2.0a7
  +  *) send_the_file now falls back to a read/write loop on platforms that
  +     do not have sendfile.
  +     [Ryan Bloom and Brian Havard]
  +
     *) Install apachectl correctly, and substitute the proper values so
        that it works again.  [Ryan Bloom]
   
  
  
  
  1.55      +1 -10     apache-2.0/src/lib/apr/include/apr_network_io.h
  
  Index: apr_network_io.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_network_io.h,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- apr_network_io.h	2000/10/07 00:37:17	1.54
  +++ apr_network_io.h	2000/10/07 21:54:15	1.55
  @@ -131,6 +131,7 @@
   #if APR_HAS_SENDFILE
   /* Define flags passed in on apr_sendfile() */
   #define APR_SENDFILE_DISCONNECT_SOCKET      1
  +#endif
   
   /** A structure to encapsulate headers and trailers for apr_sendfile */
   struct apr_hdtr_t {
  @@ -145,16 +146,6 @@
       /** number of trailers in the iovec */
       int numtrailers;
   };
  -#else
  -/* 
  - * we need to define something for non-sendfile systems, since
  - * we don't abtract out function calls (eg: send_the_file in http_core.c))
  - * depending on sendfile existance
  - */
  -struct apr_hdtr_t {
  -    int dummy;
  -};
  -#endif
   
   /* function definitions */
   
  
  
  
  1.150     +38 -11    apache-2.0/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
  retrieving revision 1.149
  retrieving revision 1.150
  diff -u -r1.149 -r1.150
  --- http_core.c	2000/10/07 18:10:02	1.149
  +++ http_core.c	2000/10/07 21:54:16	1.150
  @@ -2582,11 +2582,11 @@
                                     apr_hdtr_t *hdtr, apr_off_t offset, 
                                     apr_size_t length, apr_size_t *nbytes) 
   {
  -    apr_int32_t flags = 0;
  -    apr_status_t rv;
  +    apr_status_t rv = APR_EINIT;
       apr_size_t n = length;
   
   #if APR_HAS_SENDFILE
  +    apr_int32_t flags = 0;
       if (!c->keepalive) {
           /* Prepare the socket to be reused */
           flags |= APR_SENDFILE_DISCONNECT_SOCKET;
  @@ -2601,8 +2601,42 @@
           *nbytes = n;
           return rv;
       }
  +#else
  +    apr_int32_t sendlen = 0;
  +    apr_int32_t togo;
  +    char buffer[8192];
  +
  +    if ( hdtr && hdtr->numheaders > 0 ) {
  +        rv = apr_sendv(c->client->bsock, hdtr->headers, hdtr->numheaders, 
  +                       &sendlen);
  +    }
  +
  +    if (offset != 0 && rv == APR_SUCCESS) {
  +        rv = apr_seek(fd, APR_SET, &offset);
  +    }
  +
  +    togo = n;
  +    n = sendlen;
  +
  +    while (rv == APR_SUCCESS && togo > 0) {
  +        sendlen = togo > sizeof(buffer) ? sizeof(buffer) : togo;
  +        rv = apr_read(fd, buffer, &sendlen);
  +
  +        if (rv == APR_SUCCESS) {
  +            togo -= sendlen;
  +            rv = apr_send(c->client->bsock, buffer, &sendlen);
  +            n += sendlen;
  +        }
  +    }
  +
  +    if ( rv == APR_SUCCESS && hdtr && hdtr->numtrailers > 0 ) {
  +        rv = apr_sendv(c->client->bsock, hdtr->trailers, hdtr->numtrailers,

  +                       &sendlen);
  +        n += sendlen;
  +    }
  +
  +    return rv;
   #endif;
  -    /* XXX: apr_sendfile is not available. Use apr_send/apr_sendv instead */
   
       return APR_SUCCESS;
   }
  @@ -3377,13 +3411,7 @@
           }
           if (fd) {
               apr_hdtr_t hdtr;
  -#if APR_HAS_SENDFILE
  -/*
  - * TODO: fix the call to send_the_file somehow to remove the need for
  - * the apr_hdtr_t paramater if !APR_HAS_SENDFILE. The way it is
  - * now, we have to define a dummy apr_hdtr_t typedef and then
  - * wrap sections anyway. -- jj
  - */
  +
               memset(&hdtr, '\0', sizeof(hdtr));
               if (nvec) {
                   hdtr.numheaders = nvec;
  @@ -3393,7 +3421,6 @@
                   hdtr.numtrailers = nvec_trailers;
                   hdtr.trailers = vec_trailers;
               }
  -#endif
               rv = send_the_file(c, fd, &hdtr, foffset, flen, &bytes_sent);
           }
           else {
  
  
  

Mime
View raw message