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: Race condition in apr_file_read on Windows
Date Sat, 04 Feb 2006 21:18:33 GMT

   although I essentially grok what you are saying, please follow the
guidelines at http://apr.apache.org/patches.html so there is absolutely
no ambiguity in the fix that needs to be applied.  If you get to it right
away, this might make in into the next release, since I'm eager to close
this race condition.



Ivan Leung wrote:
> Hi,
> I found that there is race condition in apr_file_read on Windows.
> In read_with_timeout(), ReadFile() is an overlapped I/O operation
> which is waited by WaitForSingleObject() afterwards. If the
> message comes to the file handle just after
> WaitForSingleObject. (with timeout) and before CancelIo(). The message
> will be ignored and hence lost. My workaround is to check if
> there is event on file handle after CancelIo. Adds following piece
> of code just after CancelIo.
> if (rv != APR_SUCCESS) {
> if (apr_os_level >= APR_WIN_98)
> CancelIo(file->filehand);
> GetOverlappedResult(file->filehand, file->pOverlapped,
> (LPDWORD)nbytes, FALSE);
> if (*nbytes > 0)
> }

View raw message