Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 30670 invoked from network); 19 Jan 2006 07:09:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Jan 2006 07:09:30 -0000 Received: (qmail 21137 invoked by uid 500); 19 Jan 2006 07:09:29 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 21097 invoked by uid 500); 19 Jan 2006 07:09:28 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 21081 invoked by uid 99); 19 Jan 2006 07:09:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jan 2006 23:09:28 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [202.94.229.73] (HELO emerald.clustertech.com) (202.94.229.73) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jan 2006 23:09:27 -0800 Received: from [192.168.128.136] (moss.clustertech.com [192.168.128.136]) by emerald.clustertech.com (8.12.11/8.12.11) with ESMTP id k0J792N1031574 for ; Thu, 19 Jan 2006 15:09:02 +0800 Message-ID: <43CF3B0E.40909@clustertech.com> Date: Thu, 19 Jan 2006 15:09:02 +0800 From: Ivan Leung User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@apr.apache.org Subject: Race condition in apr_file_read on Windows Content-Type: text/plain; charset=Big5 Content-Transfer-Encoding: 7bit X-clustertech-MailScanner-Information: X-clustertech-MailScanner: Found to be clean X-MailScanner-From: khleung@clustertech.com X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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.