stoddard    02/05/22 11:21:46

  Modified:    network_io/win32 sendrecv.c
  Log:
  Win32: Rearrange code for clarity
  
  Revision  Changes    Path
  1.51      +12 -14    apr/network_io/win32/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sendrecv.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- sendrecv.c        20 May 2002 18:37:40 -0000      1.50
  +++ sendrecv.c        22 May 2002 18:21:46 -0000      1.51
  @@ -251,22 +251,26 @@
       OVERLAPPED overlapped;
       TRANSMIT_FILE_BUFFERS tfb, *ptfb = NULL;
       int ptr = 0;
  -    int bytes_to_send = *len;   /* Bytes to send out of the file (not 
including headers) */
  +    int bytes_to_send;   /* Bytes to send out of the file (not including 
headers) */
       int disconnected = 0;
  +    HANDLE wait_event;
   
       if (apr_os_level < APR_WIN_NT) {
           return APR_ENOTIMPL;
       }
   
  -    /* Use len to keep track of number of total bytes sent (including 
headers) */
  -    *len = 0;
  -
       /* Initialize the overlapped structure */
       memset(&overlapped,'\0', sizeof(overlapped));
   #ifdef WAIT_FOR_EVENT
  -    overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  +    wait_event = overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  +#else
  +    wait_event = (HANDLE) sock->sock;
   #endif
   
  +    /* Use len to keep track of number of total bytes sent (including 
headers) */
  +    bytes_to_send = *len;
  +    *len = 0;
  +
       /* Handle the goofy case of sending headers/trailers and a zero byte 
file */
       if (!bytes_to_send && hdtr) {
           if (hdtr->numheaders) {
  @@ -328,17 +332,12 @@
               status = apr_get_netos_error();
               if ((status == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) ||
                   (status == APR_FROM_OS_ERROR(WSA_IO_PENDING))) {
  -                HANDLE event;
  -#ifdef WAIT_FOR_EVENT
  -                event = overlapped.hEvent;
  -#else
  -                event = (HANDLE) sock->sock;
  -#endif
  -                rv = WaitForSingleObject(event, 
  +
  +                rv = WaitForSingleObject(wait_event, 
                                            (DWORD)(sock->timeout >= 0 
                                                    ? sock->timeout : 
INFINITE));
                   if (rv == WAIT_OBJECT_0) {
  -                    if (!disconnected && !GetOverlappedResult(event, 
&overlapped,
  +                    if (!disconnected && !GetOverlappedResult(wait_event, 
&overlapped,
                                                                 &nbytes, 
FALSE)) {
                           status = APR_FROM_OS_ERROR(GetLastError());
                       }
  @@ -374,7 +373,6 @@
           *len += nbytes;
           curoff += nbytes;
       }
  -
   
       if (status == APR_SUCCESS) {
           if (ptfb && ptfb->TailLength)
  
  
  

Reply via email to