delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/06/01/08:57:59

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=w2vsrgIW6GJUyCYZpnTgJ8B6iC/nmv2qMcHhtDStRQJC0jHXhKbhC
BO6nIaAQWXmi45nHXK4yxY3TuD5Wdj4lRUXWu915m8bu33inRGLWkgn4qG9DBACw
otqn+AiwxMeAHn1tDsJNuk/MPN9qc5MtvVj1IyZdtfeZAlfJTQ/Ocs=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=RtjARsMYxeAr48erFVwl/T5ci14=; b=drd1of6i5pOzM/jQ4lLR+DKO8Rmf
t9DqSUb19VDzflb0R0171+XjT3MF5iDayiE8v0Pdx+DwBW0vU46H2C351mp5pZbw
SW+wal3sxIRV8D+EbOBCMnCn8Jgj4IIw/38h0B5lwatxAk9HvdFizAF2LZ7e1YS5
ntVgtWlxcZzDyK8=
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
X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,TW_FC autolearn=ham version=3.3.1
Date: Sat, 1 Jun 2013 14:57:38 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: sqlite3: bug with monotone
Message-ID: <20130601125738.GF30659@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <51A6B6EB DOT 6050309 AT users DOT sourceforge DOT net> <loom DOT 20130530T122354-144 AT post DOT gmane DOT org> <51A7862F DOT 1070507 AT etr-usa DOT com> <51A7D47E DOT 3050502 AT users DOT sourceforge DOT net> <51A7F547 DOT 6020509 AT etr-usa DOT com> <20130531092228 DOT GB30659 AT calimero DOT vinschen DOT de> <51A900EF DOT 2020606 AT etr-usa DOT com> <20130601105741 DOT GC30659 AT calimero DOT vinschen DOT de> <20130601113531 DOT GE30659 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20130601113531.GE30659@calimero.vinschen.de>
User-Agent: Mutt/1.5.21 (2010-09-15)

On Jun  1 13:35, Corinna Vinschen wrote:
> On Jun  1 12:57, Corinna Vinschen wrote:
> > There's a lot to recommend not using mandatory locking at all, unless in
> > very limited circumstances where interoperability with native
> > applications using mandatory locking is required.  For one thing, this
> > doesn't occur very often, since mandatory record locking isn't used
> > a lot, not even on Windows.  But what's more important is that Windows
> > mandatory record locking works not as the user can usually expect from
> > fcntl or flock: Windows locks are per-process/per-handle.  Locks are not
>                                     ^^^^^^^^^^^^^^^^^^^^^^
> 
> Make that "per-process/per-file object".
> 
> To clarify: The file object is the OS datastructure the handles refer
> to.  A duplicated handle refers to the same file object, while a handle
> to the same file created with CreateFile refers to another file object.
> 
> Duplicated handles within the same process share the locks.  Different
> handles to the same file created with CreateFile don't share the locks.
> 
> Duplicated handles to the same file object in another process (via
> inheritance or an explicit DuplicateHandle) don't share the locks.

Oh and, while I'm at it, here's another inconsistency:

fcntl locks, when owned, can be overwritten with another lock type
(F_RDLCK/F_WRLCK) without having to unlock the existing lock first.
fcntl locks can be locked and unlocked byte per byte on an as needed
basis.  Locks are split and merged as you lock along.

This doesn't work at all with Windows mandatory locks.  The owning
handle can overwrite read locks with other read locks, but they are not
merged.  Rather they add up and each of them has to be explicitly
unlocked to get out of the way.  The owning handle can't overwrite a
read lock with a write lock at all.  The owning handle can't overwrite a
write lock with an identical write lock.  Locked regions can't be
unlocked partially, they have to be unlocked exactly the same offset and
length as they have been locked.  Therefore, there's no atomic way to
convert arbitrary regions from one lock type to another, unless it's
guaranteed that the lock/unlock calls are guarded in a cooperative way.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

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

- Raw text -


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