apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garrett Rooney <roo...@electricjellyfish.net>
Subject Re: Race condition in apr_file_read on Windows
Date Thu, 19 Jan 2006 20:55:51 GMT
On 1/18/06, Ivan Leung <khleung@clustertech.com> 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)
> }

I don't know nearly enough about windows programming to say if you're
correct or not, but sending a patch instead of just a "put this chunk
of code in" description of what needs to be done would make it
infinitely more likely for a developer to evaluate and commit the fix.


View raw message