Ivan, 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. Yours, Bill 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) > rv = APR_SUCCESS; > } >