apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Leung <khle...@clustertech.com>
Subject Race condition in apr_file_read on Windows
Date Thu, 19 Jan 2006 07:09:02 GMT

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)
GetOverlappedResult(file->filehand, file->pOverlapped,
(LPDWORD)nbytes, FALSE);
if (*nbytes > 0)

Ivan Leung
Clustertech Ltd.

View raw message