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
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;
}

-- 
Regards,
Ivan Leung
Clustertech Ltd.


Mime
View raw message