delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/04/20/13:46:18

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Eric Blake <ebb9 AT byu DOT net>
Subject: Re: [1.7] flock change breaks autotools 'make -j2'
Date: Mon, 20 Apr 2009 17:45:50 +0000 (UTC)
Lines: 45
Message-ID: <loom.20090420T170835-58@post.gmane.org>
References: <loom DOT 20090416T201917-225 AT post DOT gmane DOT org> <20090417100148 DOT GD5200 AT calimero DOT vinschen DOT de> <49E87CFA DOT 9070709 AT byu DOT net> <20090417133103 DOT GG8722 AT calimero DOT vinschen DOT de> <loom DOT 20090420T150238-584 AT post DOT gmane DOT org> <20090420153442 DOT GB8722 AT calimero DOT vinschen DOT de>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:

> Because this testcase works fine.  I hope it's not trying to do this:
> 
>   parent opens file
>   fork
>     child calls flock()
>     exit
>   fork
>     second child relies on the lock.
> 
> because this is exactly the scenario which doesn't work with flock
> right now.  I have it on my TODO list, but so far I'm at a loss as
> to how to implement it.

As far as I can tell, the original case doesn't look like that.  From the 
strace I ran, flock was only called on the fd obtained several lines earlier by 
the same perl process, and I don't see any child processes trying to perform 
flock manipulations on the fd inherited from the parent.  But I'm still trying 
to figure out what is different between the 'make -j2' case and my simpler C 
program (which I wrote before I saw this mail, but which looked awfully similar 
to yours).

I did notice that flock only seems to protect processes spawned in the same 
cygwin process hierarchy - using strace to spawn my test program created a new 
hierarchy, and thus did not see the lock held by the old hierarchy.  That does 
not affect the original testcase, where all processes involved are in the same 
hierarchy.  And I guess it makes sense - since we aren't modifying the inodes 
of the actual file system, the cygwin notion of an inode (where BSD flock 
locking takes place) is necessarily limited to the shared memory among a cygwin 
process hierarchy, and we shouldn't have to worry about independent process 
hierarchies.  But it does mean that it is harder to debug the issue, because it 
is no longer a simple matter of using strace or gdb to run the test app, but 
instead requires process attachment to keep the test programs within the same 
process hierarchy.

Maybe we should teach strace to output when an flock release occurs due to 
closing the last handle to a file, to see if that sheds any more insight.  
Perhaps also an strace line just before a process blocks because it detects 
that some other process already holds a lock; if nothing else, so that we can 
see how long the flock call blocks?

-- 
Eric Blake



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019