--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id C69FB431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 29 Feb 2012 14:18:01 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id lgBaSWQHLk8X for <notmuch@notmuchmail.org>;\r
+ Wed, 29 Feb 2012 14:18:01 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+ [18.9.25.14])\r
+ by olra.theworths.org (Postfix) with ESMTP id 21B99431E64\r
+ for <notmuch@notmuchmail.org>; Wed, 29 Feb 2012 14:18:01 -0800 (PST)\r
+X-AuditID: 1209190e-b7f7c6d0000008c3-49-4f4ea4161541\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id DD.0B.02243.614AE4F4; Wed, 29 Feb 2012 17:17:58 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q1TMHulA025287; \r
+ Wed, 29 Feb 2012 17:17:57 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q1TMHsKv004790\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Wed, 29 Feb 2012 17:17:55 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1S2rqM-0002Zt-EE; Wed, 29 Feb 2012 17:17:54 -0500\r
+Date: Wed, 29 Feb 2012 17:17:54 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+Subject: Re: [PATCH] Actually close the xapian database in\r
+ notmuch_database_close\r
+Message-ID: <20120229221754.GD772@mit.edu>\r
+References:\r
+ <1330507157-22859-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+ <1330507157-22859-2-git-send-email-4winter@informatik.uni-hamburg.de>\r
+ <20120229154833.GB772@mit.edu> <20120229211922.GQ24964@survex.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <20120229211922.GQ24964@survex.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42IRYrdT1xVb4udv0LZXwGJ26w8mi+s3ZzJb\r
+ 3F/+ntWB2WPi+dNsHs9W3WL2WLfzD3sAcxSXTUpqTmZZapG+XQJXxszVK1gKpvNWTP19iqmB\r
+ 8SBXFyMnh4SAicSvk+/YIGwxiQv31gPZXBxCAvsYJeZdWMEI4WxglOheOZEVwjnJJDF9+1ko\r
+ ZwmjxP4rq8H6WQRUJS4svMkIYrMJaEhs278czBYRMJXY8OABO4jNLGApcXXGNFYQW1ggWOLU\r
+ 5NNgvbwCWhLnv60DqxESeMAocfkMJ0RcUOLkzCcsEL1aEjf+vWTqYuQAsqUllv/jAAlzChhI\r
+ PNmwB6xVVEBFYsrJbWwTGIVmIemehaR7FkL3AkbmVYyyKblVurmJmTnFqcm6xcmJeXmpRbrG\r
+ ermZJXqpKaWbGEHBzinJt4Px60GlQ4wCHIxKPLxMhX7+QqyJZcWVuYcYJTmYlER5TecDhfiS\r
+ 8lMqMxKLM+KLSnNSiw8xSnAwK4nwfuwGyvGmJFZWpRblw6SkOViUxHnVtN75CQmkJ5akZqem\r
+ FqQWwWRlODiUJHh/LwJqFCxKTU+tSMvMKUFIM3FwggznARqutxhkeHFBYm5xZjpE/hSjopQ4\r
+ LydIQgAkkVGaB9cLS0avGMWBXhGGaOcBJjK47ldAg5mABgdweoMMLklESEk1MLqqfSutZ+tn\r
+ Wvxv/R853r9VC6OkxNcpVu4+zK5/La5y1Xxr16n9W35r7XiexvWPa+fKmam2f+Kl/30M4D2h\r
+ d3ji3CKeCTaOGz9tTZv9KZRrv05r979VWx0LV1wN3lVvHla/cuIFZZ07U1PvMh0x8/9ldtWo\r
+ 85zQbwf2lPLUtfOfTefX3HZn/18lluKMREMt5qLiRAA1lO7IIQMAAA==\r
+Cc: Olly Betts <olly@survex.com>, notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 29 Feb 2012 22:18:01 -0000\r
+\r
+Quoth Olly Betts on Feb 29 at 9:19 pm:\r
+> On Wed, Feb 29, 2012 at 10:48:33AM -0500, Austin Clements wrote:\r
+> > Quoth Justus Winter on Feb 29 at 10:19 am:\r
+> > > Formerly the xapian database object was deleted and closed in its\r
+> > > destructor once the object was garbage collected. Explicitly call\r
+> > > close() so that the database and the associated lock is released\r
+> > > immediately.\r
+> > \r
+> > Interesting. Is this a bug in Xapian? According to the docs,\r
+> > ~Database is supposed to close the database (if there are no other\r
+> > copies, which there shouldn't be), so this should be redundant with\r
+> > the delete notmuch->xapian_db a few lines down, but your experience\r
+> > obviously suggests that it isn't and I can't find the code path in\r
+> > Xapian that would close it in the destructor.\r
+> \r
+> Most Xapian API classes (including Database and WritableDatabase) just\r
+> hold a reference-counted pointer, and so it's the destructor of the\r
+> reference-counted object which closes the database. If "PIMPL" means\r
+> anything to you, that's what we have here.\r
+> \r
+> Some other API classes objects (such as PostingIterator) internally hold\r
+> a reference to the database they are using, so calling close()\r
+> explicitly is useful if you don't want to have to worry about such\r
+> objects still existing and holding onto references which keep the\r
+> database open.\r
+\r
+Makes sense. Justus, could you add a comment to your patch explaining\r
+that we explicitly close the database because there may be other\r
+objects with references to it that would keep it open?\r
+\r
+Also, since close could throw an exception, it should get wrapped in a\r
+try/catch like flush currently is.\r