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 Fri, 17 May 2002 18:01:14 GMT
gregames    02/05/17 11:01:14

  Modified:    network_io/unix sendrecv.c
  Log:
  linux sendfile:  exit with an error if the file gets smaller in the middle of
  a request.
  
  With this patch, a faked up shrinking file, and LogLevel info, the log contains:
  [Fri May 17 13:34:45 2002] [info] (20514)End of file found: core_output_filter:
  writing data to the network
  
  ...and the assert in sendfile_it_all doesn't hit.
  
  Is APR_EOF appropriate?  beats me; it gets the job done.  If you think of
  something better, please speak up soon because I plan on doing FreeBSD next.
  
  Revision  Changes    Path
  1.83      +19 -7     apr/network_io/unix/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- sendrecv.c	25 Apr 2002 18:27:31 -0000	1.82
  +++ sendrecv.c	17 May 2002 18:01:14 -0000	1.83
  @@ -390,16 +390,28 @@
   
       nbytes += rv;
   
  -    /* If this was a partial write, return now with the partial byte count; 
  -     * this is a non-blocking socket.
  -     */
  -
       if (rv < *len) {
           *len = nbytes;
  -        if (sock->timeout) {
  -            sock->netmask |= APR_INCOMPLETE_WRITE;
  +        arv = apr_setsocketopt(sock, APR_TCP_NOPUSH, 0);
  +        if (rv > 0) {
  +                
  +            /* If this was a partial write, return now with the 
  +             * partial byte count;  this is a non-blocking socket.
  +             */
  +
  +            if (sock->timeout) {
  +                sock->netmask |= APR_INCOMPLETE_WRITE;
  +            }
  +            return arv;
  +        }
  +        else {
  +            /* If the file got smaller mid-request, eventually the offset
  +             * becomes equal to the new file size and the kernel returns 0.  
  +             * Make this an error so the caller knows to log something and
  +             * exit.
  +             */
  +            return APR_EOF;
           }
  -        return apr_setsocketopt(sock, APR_TCP_NOPUSH, 0);
       }
   
       /* Now write the footers */
  
  
  

Mime
View raw message