From f45b8ee9c9db29123194252c6fb04465635a169c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Feb 2012 21:19:22 +0000 Subject: [PATCH] Re: [PATCH] Actually close the xapian database in notmuch_database_close --- 57/5ebe81ccb3a3f19e39fd59b7e186a1ca995c8f | 89 +++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 57/5ebe81ccb3a3f19e39fd59b7e186a1ca995c8f diff --git a/57/5ebe81ccb3a3f19e39fd59b7e186a1ca995c8f b/57/5ebe81ccb3a3f19e39fd59b7e186a1ca995c8f new file mode 100644 index 000000000..a7ca7aa21 --- /dev/null +++ b/57/5ebe81ccb3a3f19e39fd59b7e186a1ca995c8f @@ -0,0 +1,89 @@ +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 33060431E64 + for ; Wed, 29 Feb 2012 13:19:29 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.3 +X-Spam-Level: +X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3] 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 MMKVcRo9quLs for ; + Wed, 29 Feb 2012 13:19:28 -0800 (PST) +Received: from atreus.tartarus.org (atreus.tartarus.org [80.252.125.10]) + (using TLSv1 with cipher AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 48740431FAE + for ; Wed, 29 Feb 2012 13:19:28 -0800 (PST) +Received: from olly by atreus.tartarus.org with local (Exim 4.69) + (envelope-from ) + id 1S2qvi-00067j-MC; Wed, 29 Feb 2012 21:19:22 +0000 +Date: Wed, 29 Feb 2012 21:19:22 +0000 +From: Olly Betts +To: Austin Clements +Subject: Re: [PATCH] Actually close the xapian database in + notmuch_database_close +Message-ID: <20120229211922.GQ24964@survex.com> +References: + <1330507157-22859-1-git-send-email-4winter@informatik.uni-hamburg.de> + <1330507157-22859-2-git-send-email-4winter@informatik.uni-hamburg.de> + <20120229154833.GB772@mit.edu> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20120229154833.GB772@mit.edu> +User-Agent: Mutt/1.5.18 (2008-05-17) +Cc: notmuch@notmuchmail.org +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: Wed, 29 Feb 2012 21:19:29 -0000 + +On Wed, Feb 29, 2012 at 10:48:33AM -0500, Austin Clements wrote: +> Quoth Justus Winter on Feb 29 at 10:19 am: +> > Formerly the xapian database object was deleted and closed in its +> > destructor once the object was garbage collected. Explicitly call +> > close() so that the database and the associated lock is released +> > immediately. +> +> Interesting. Is this a bug in Xapian? According to the docs, +> ~Database is supposed to close the database (if there are no other +> copies, which there shouldn't be), so this should be redundant with +> the delete notmuch->xapian_db a few lines down, but your experience +> obviously suggests that it isn't and I can't find the code path in +> Xapian that would close it in the destructor. + +Most Xapian API classes (including Database and WritableDatabase) just +hold a reference-counted pointer, and so it's the destructor of the +reference-counted object which closes the database. If "PIMPL" means +anything to you, that's what we have here. + +Some other API classes objects (such as PostingIterator) internally hold +a reference to the database they are using, so calling close() +explicitly is useful if you don't want to have to worry about such +objects still existing and holding onto references which keep the +database open. + +The main motivation for adding close() was the bindings though - e.g. in +Python the wrapped Database object gets destroyed when the GC gets run, +which is at some essentially arbitrary time after you remove the last +reference to it. + +It is hard to say if calling close() is actually useful here from just +seeing the patch. + +Cheers, + Olly -- 2.26.2