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/win32 sendrecv.c
Date Wed, 22 May 2002 19:11:31 GMT
stoddard    02/05/22 12:11:31

  Modified:    network_io/win32 sendrecv.c
  Log:
  Win32: Fix bug introduced by the commit that added GetOverlappedResults()
  where apr_sendfile() wwould not properly send files over MAX_SEGMENT_SIZE.
  
  Revision  Changes    Path
  1.52      +17 -12    apr/network_io/win32/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sendrecv.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- sendrecv.c	22 May 2002 18:21:46 -0000	1.51
  +++ sendrecv.c	22 May 2002 19:11:31 -0000	1.52
  @@ -289,8 +289,8 @@
       }
   
       /* Collapse the headers into a single buffer */
  -    memset(&tfb, '\0', sizeof (tfb));
       if (hdtr && hdtr->numheaders) {
  +        memset(&tfb, '\0', sizeof (tfb));
           ptfb = &tfb;
           collapse_iovec((char **)&ptfb->Head, &ptfb->HeadLength, hdtr->headers,

                          hdtr->numheaders, sock->cntxt);
  @@ -305,6 +305,7 @@
               nbytes = bytes_to_send;
               /* Collapse the trailers into a single buffer */
               if (hdtr && hdtr->numtrailers) {
  +                memset(&tfb, '\0', sizeof (tfb));
                   ptfb = &tfb;
                   collapse_iovec((char**) &ptfb->Tail, &ptfb->TailLength, 
                                  hdtr->trailers, hdtr->numtrailers, sock->cntxt);
  @@ -332,7 +333,6 @@
               status = apr_get_netos_error();
               if ((status == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) ||
                   (status == APR_FROM_OS_ERROR(WSA_IO_PENDING))) {
  -
                   rv = WaitForSingleObject(wait_event, 
                                            (DWORD)(sock->timeout >= 0 
                                                    ? sock->timeout : INFINITE));
  @@ -343,6 +343,15 @@
                       }
                       else {
                           status = APR_SUCCESS;
  +                        /* Ugly Code Alert:
  +                         * Account for the fact that GetOverlappedResult
  +                         * tracks bytes sent in headers, trailers and the file 
  +                         * and this loop only needs to track bytes sent out 
  +                         * of the file.
  +                         */
  +                        if (ptfb) {
  +                            nbytes -= (ptfb->HeadLength + ptfb->TailLength);
  +                        }
                       }
                   }
                   else if (rv == WAIT_TIMEOUT)
  @@ -363,21 +372,17 @@
           if (status != APR_SUCCESS)
               break;
   
  -        /* Assume the headers have been sent */
  -        if (ptfb != NULL) {
  -            *len += ptfb->HeadLength;
  -            ptfb->HeadLength = 0;
  -            ptfb->Head = NULL;
  -        }
           bytes_to_send -= nbytes;
  -        *len += nbytes;
           curoff += nbytes;
  +        *len += nbytes;
  +        /* Adjust len for any headers/trailers sent */
  +        if (ptfb) {
  +            *len += (ptfb->HeadLength + ptfb->TailLength);
  +            ptfb = NULL;
  +        }
       }
   
       if (status == APR_SUCCESS) {
  -        if (ptfb && ptfb->TailLength)
  -            *len += ptfb->TailLength;
  -
           /* Mark the socket as disconnected, but do not close it.
            * Note: The application must have stored the socket prior to making
            * the call to apr_sendfile in order to either reuse it or close it.
  
  
  

Mime
View raw message