apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: [PATCH] win32 - dropped data in read_with_timeout
Date Mon, 20 Mar 2006 07:45:30 GMT
This patch looks correct, and because of the nature of the flaw it fixes,
this is issue 2/2 that held me up this weekend.

The reason I've not committed your patch verbatim, is that I'm trying to
grok the expected and unexpected result codes that arise in this situation.

You also ignore the result of the CancelIo() call which troubles me, we
should be able to reduce that result to one of two expected values as well.

Bill

Norris Leong wrote:
> Hi All,
> 
> I suspect that read_with_timeout (in file_io/win32/readwrite.c) may drop 
> data if
> 
> (i) WaitForSingleObject (line 82) returns WAIT_TIMEOUT, and
> (ii) Data arrived before the execution arrives at CancelIo (line 105).
> 
> Tried the attached patch and the problem seems solved.  I'm a novice of 
> Windows' file mgmt API and would appreciate if somebody can validate 
> this patch.
> 
> Regards,
> Norris Leong
> 
> 
> ------------------------------------------------------------------------
> 
> diff -ruN apr-1.2.2.orig/file_io/win32/readwrite.c apr-1.2.2/file_io/win32/readwrite.c
> --- apr-1.2.2.orig/file_io/win32/readwrite.c	2006-01-20 11:46:52.000000000 +0800
> +++ apr-1.2.2/file_io/win32/readwrite.c	2006-01-20 11:41:13.000000000 +0800
> @@ -102,7 +102,12 @@
>              }
>              if (rv != APR_SUCCESS) {
>                  if (apr_os_level >= APR_WIN_98)
> +                {
>                      CancelIo(file->filehand);
> +                    if (GetOverlappedResult(file->filehand, file->pOverlapped,

> +                                        (LPDWORD)nbytes, TRUE))
> +                        rv = APR_SUCCESS;
> +                }
>              }
>          }
>          else if (rv == APR_FROM_OS_ERROR(ERROR_BROKEN_PIPE)) {


Mime
View raw message