You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Norris Leong <mp...@clustertech.com> on 2006/01/20 05:15:35 UTC
[PATCH] win32 - dropped data in read_with_timeout
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
Re: [PATCH] win32 - dropped data in read_with_timeout
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
William A. Rowe, Jr. wrote:
> 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.
FYI - this is considered a non-issue by our 1.2 RM, so I am not addressing
it in the current release cycle as it's more important to tag a 0.9 release
matching the current 1.2, and it's something to address in the next cycle
when we also catch the WAIT_ABANDONED case.
Note that I'm still stuck trying to envision a current use case for this
exception in any Apache code. The WAIT_ABANDONED case is not an issue in
correctly written code, since the the thread holding a lock should -not-
be abruptly terminated in any normal case. The TIMEOUT case is not an issue
if there is a timeout, since traditional network apps will abandon the
client / server when it hasn't responded in the specified TIMEOUT. The
only case I can envison where this particular fix is effective, is in the
case of a nonblocking ping, timeout 0, looking to see if the channel is
ready. In that edge case, I can see data arriving in the small window
before we give up.
Note also this is not the only occurance in the code of this condition,
and it is interrelated to the WAIT_ABANONDED case, which is why the correct
patch is far more complex.
Let us know if we've misunderstood your expected cases.
Bill
Re: [PATCH] win32 - dropped data in read_with_timeout
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
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)) {
Re: [PATCH] win32 - dropped data in read_with_timeout
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 1/29/06, James Mansion <ja...@wgold.demon.co.uk> wrote:
> >race in practice, or is it just a theoretical possibility? I'm only
> >asking because I'd be much more comfortable applying a patch if the
> >contributor can say "this actually fixes a reproducable problem" ;-)
>
> Are you suggesting that 'wrong by inspection' isn't reproducable?
>
> I know this sounds facetious, but race conditions are a pain to
> test for and really careful review of design and implementation
> is the answer IMO.
I'm saying that I don't know enough about win32 programming to
determine if something is "wrong" just by looking at it, so if I'm
actually going to commit this change I'd like to hear some indication
that it can actually happen. Not to say that someone more comfortable
in this environment wouldn't just commit the change after seeing the
code, but I simply don't know enough to do that.
-garrett
RE: [PATCH] win32 - dropped data in read_with_timeout
Posted by James Mansion <ja...@wgold.demon.co.uk>.
>race in practice, or is it just a theoretical possibility? I'm only
>asking because I'd be much more comfortable applying a patch if the
>contributor can say "this actually fixes a reproducable problem" ;-)
Are you suggesting that 'wrong by inspection' isn't reproducable?
I know this sounds facetious, but race conditions are a pain to
test for and really careful review of design and implementation
is the answer IMO.
James
Re: [PATCH] win32 - dropped data in read_with_timeout
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 1/19/06, Norris Leong <mp...@clustertech.com> 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.
This seems reasonable to me, although I'm not anywhere close to a
win32 expert, so I can't say for sure. Have you actually seen this
race in practice, or is it just a theoretical possibility? I'm only
asking because I'd be much more comfortable applying a patch if the
contributor can say "this actually fixes a reproducable problem" ;-)
-garrett