--- /dev/null
+Return-Path: <aclements@csail.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 1FAD1431FBC\r
+ for <notmuch@notmuchmail.org>; Thu, 2 Oct 2014 13:39:53 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] 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 zUY7V3CUtcgU for <notmuch@notmuchmail.org>;\r
+ Thu, 2 Oct 2014 13:39:45 -0700 (PDT)\r
+Received: from outgoing.csail.mit.edu (outgoing.csail.mit.edu [128.30.2.149])\r
+ by olra.theworths.org (Postfix) with ESMTP id EC8B7431FB6\r
+ for <notmuch@notmuchmail.org>; Thu, 2 Oct 2014 13:39:44 -0700 (PDT)\r
+Received: from [104.131.20.129] (helo=awakeningjr)\r
+ by outgoing.csail.mit.edu with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16)\r
+ (Exim 4.72) (envelope-from <aclements@csail.mit.edu>)\r
+ id 1XZnA6-0001qT-4v; Thu, 02 Oct 2014 16:39:42 -0400\r
+Received: from amthrax by awakeningjr with local (Exim 4.84)\r
+ (envelope-from <aclements@csail.mit.edu>)\r
+ id 1XZnA5-000627-Oa; Thu, 02 Oct 2014 16:39:41 -0400\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: "W. Trevor King" <wking@tremily.us>\r
+Subject: Re: [PATCH v4] lib: Simplify close and codify aborting atomic section\r
+In-Reply-To: <20141002194134.GP3770@odin.tremily.us>\r
+References: <87mw9ee0vf.fsf@csail.mit.edu>\r
+ <1412277548-3445-1-git-send-email-aclements@csail.mit.edu>\r
+ <20141002194134.GP3770@odin.tremily.us>\r
+User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Thu, 02 Oct 2014 16:39:41 -0400\r
+Message-ID: <87k34idx4i.fsf@csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: 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: Thu, 02 Oct 2014 20:39:53 -0000\r
+\r
+On Thu, 02 Oct 2014, "W. Trevor King" <wking@tremily.us> wrote:\r
+> On Thu, Oct 02, 2014 at 03:19:08PM -0400, Austin Clements wrote:\r
+>> This patch simplifies notmuch_database_close to explicitly abort any\r
+>> outstanding transaction and then just call Database::close. This\r
+>> works for both read-only and read/write databases, takes care of\r
+>> committing changes, unifies the exception handling path, and codifies\r
+>> aborting outstanding transactions.\r
+>\r
+> I don't expect atomic blocks are particularly useful for read-only\r
+> connections. If they aren't, I'd quibble with the =E2=80=9CThis works for\r
+> both read-only=E2=80=A6=E2=80=9D wording above. If they are, I'd drop th=\r
+e read/write\r
+\r
+It's true that atomic sections aren't very useful on a read-only\r
+database, but we do allow them for symmetry. We also keep track of how\r
+deeply nested we are so notmuch_database_end_atomic can return a proper\r
+error message regardless of whether the database is read/write or\r
+read-only.\r
+\r
+But all I'm saying in the commit message is that Xapian::Database::close\r
+works for both read-only and read/write databases and will flush if\r
+necessary, so we don't have to worry about that.\r
+\r
+> check below:\r
+>\r
+>> + /* If there's an outstanding transaction, it's unclear if\r
+>> + * closing the Xapian database commits everything up to\r
+>> + * that transaction, or may discard committed (but\r
+>> + * unflushed) transactions. To be certain, explicitly\r
+>> + * cancel any outstanding transaction before closing. */\r
+>> + if (notmuch->mode =3D=3D NOTMUCH_DATABASE_MODE_READ_WRITE &&\r
+>> + notmuch->atomic_nesting)\r
+>> + (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))\r
+>> + ->cancel_transaction ();\r
+\r
+The notmuch->mode check here is necessary because atomic_nesting can be\r
+non-zero on a read-only database (for the reason I mentioned above), but\r
+we had better not cast xapian_db to a WritableDatabase if it isn't a\r
+WritableDatabase.\r
+\r
+> Thats a very minor quibble though, and I'd be glad to see this patch\r
+> land as is.\r
+>\r
+> Cheers,\r
+> Trevor\r
+>\r
+> --=20\r
+> This email may be signed or encrypted with GnuPG (http://www.gnupg.org).\r
+> For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\r