Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1D875431FB6 for ; Fri, 28 Jan 2011 07:36:29 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uMgSfrsaY5-T for ; Fri, 28 Jan 2011 07:36:27 -0800 (PST) Received: from everglades.pioto.org (mail.pioto.org [207.192.71.235]) by olra.theworths.org (Postfix) with ESMTP id 5A934431FB5 for ; Fri, 28 Jan 2011 07:36:27 -0800 (PST) Received: by everglades.pioto.org (Postfix, from userid 1000) id 111AD16170F; Fri, 28 Jan 2011 10:36:16 -0500 (EST) From: Mike Kelly Subject: Re: notmuch's idea of concurrency / failing an invocation To: notmuch@notmuchmail.org References: <87fwsetdin.fsf@kepler.schwinge.homeip.net> <8762taxk9y.fsf@algae.riseup.net> <87vd1a84qj.fsf@servo.finestructure.net> <87fwsdobpy.fsf@yoom.home.cworth.org> <877hdps6og.fsf@kepler.schwinge.homeip.net> In-Reply-To: <877hdps6og.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Date: Fri, 28 Jan 2011 15:36:15 +0000 Message-Id: <1296228975-ner-3626@everglades> Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2011 15:36:29 -0000 On Fri, 28 Jan 2011 10:45:19 +0100, Thomas Schwinge wrote: > > It would definitely be nice to avoid the complexity inherent in having a > > daemon, but how do you imagine "queue on a lock" to work? We don't have > > anything like that in place now. > > I suppose what he means is trying to get the lock, and if that fails wait > a bit / wait until it is available again. > > Actually, as a next step, wouldn't it also be possible to add some > heuristic to avoid ``notmuch new'' (being a low-priority task) blocking > some interactive user (UI; high-priority task)? But we can pursue such > schemes as soon as the basic infrastructure is in place. Couldn't we pretty much get the desired behavior by using flock(2)? Basically, take out a LOCK_EX when we need to write, and a LOCK_SH when we only need to read. Using the blocking form, things should pretty much just queue up and take their turn, right? I'm not familiar with Xapian, but if it doesn't give us something we could use this sort of locking on, couldn't we just add some /path/to/mail/.notmuch.lock file that we open to hold a lock on? We already have to specify if we want a read-only or read-write database handle in notmuch_database_open, so it seems like it'd be easy enough to hook in there. -- Mike Kelly