Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 77076 invoked from network); 10 Oct 2010 01:34:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Oct 2010 01:34:56 -0000 Received: (qmail 11231 invoked by uid 500); 10 Oct 2010 01:34:55 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 11156 invoked by uid 500); 10 Oct 2010 01:34:55 -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 11149 invoked by uid 99); 10 Oct 2010 01:34:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Oct 2010 01:34:55 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of brian.havard@gmail.com designates 209.85.212.178 as permitted sender) Received: from [209.85.212.178] (HELO mail-px0-f178.google.com) (209.85.212.178) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Oct 2010 01:34:47 +0000 Received: by pxi16 with SMTP id 16so1043234pxi.37 for ; Sat, 09 Oct 2010 18:34:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=wNET/ySj/N3mntAmc5olK4XEbVjCc3Hkt0SkzQBqPmc=; b=Veq5s9X2a2M2yAlC3sZ0hxOpkJ4ym/N4ozE9ph7YricVohLvAKYSs663kW03GGFuqu dFGulOP1vgCLdsaU0Lqzo8J6zQ4FwBwlePJTw5AYG6Uh09iTK4s3jTvstTEsh35VXU/V VV7uuSSeyWtwVIyUs+ntaqozBFEIqJ2O3sUNo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=W9Ku7BBkIjmYN+1kF3nhIXFPxQh+fl3hv5r3iQ7iGjIFWLedf5rVdgsK14oukDd5Q7 dbL0DMQ2SkHA1V7qWny4rjgiTK+RAvRRonNw+EPJ3bP6nwbjbkNv4AbTMkAiIMa1xzom 23QifNsc6zJU9RNNCsFslPBHsb+BPLbzZvy1U= Received: by 10.142.44.14 with SMTP id r14mr3702151wfr.152.1286674466126; Sat, 09 Oct 2010 18:34:26 -0700 (PDT) Received: from [192.168.0.5] (ppp118-209-192-5.lns20.mel6.internode.on.net [118.209.192.5]) by mx.google.com with ESMTPS id c15sm5920606wam.0.2010.10.09.18.34.23 (version=SSLv3 cipher=RC4-MD5); Sat, 09 Oct 2010 18:34:24 -0700 (PDT) Message-ID: <4CB1181D.8060902@gmail.com> Date: Sun, 10 Oct 2010 12:34:21 +1100 From: Brian Havard User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 MIME-Version: 1.0 To: dev@apr.apache.org Subject: Re: Deadlock with apr_file_open(APR_FOPEN_APPEND) and apr_file_lock() under Windows References: <4CAB60B2.7090501@myarm.com> <4CAF0CB7.8040705@myarm.com> In-Reply-To: <4CAF0CB7.8040705@myarm.com> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 08/10/10 23:21, Stefan Ruppert wrote: > I have filed a bug in bugzilla for this issue: > > https://issues.apache.org/bugzilla/show_bug.cgi?id=50058 > > and added a patch which simple removes the calls to apr_file_lock() > and apr_file_unlock()! > > Please can some test this!? As I remember it, the file lock is used to ensure proper appending behaviour. This is necessary because windows doesn't natively have an append mode so it's necessary to seek to the end of the file then write. The file lock is used to prevent a race condition when multiple threads/processes are writing to the same file simultaneously. The deadlock problem needs to be solved by suppressing locking for append if a lock is already held, not by simply removing the locking completely. > Stefan Ruppert wrote: >> Hi all, >> >> yesterday I ran into the following problem. I use the apr_file_lock() >> function in conjunction with the APR_FOPEN_APPEND flag and under >> Linux everything is fine. >> >> Under Windows any attempt to write to the opened and locked file I >> get a deadlock. This is due the fact that apr_file_write() creates an >> own lock with apr_file_lock() if the file was opened with the >> APR_FOPEN_APPEND flag. >> >> First this is inconsistent through different operating systems Unix >> does not lock, Windows does lock the file in append mode. However, I >> think the locking in the Windows implementation is wrong. The user >> has to choose if he wants to lock the file or not! >> >> To reproduce the behavior please compile and test the attached example! >> >> Any comments? Should I file a bug report? >> >> Regards, >> Stefan >> >