--- /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 34240431FC4\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Dec 2013 08:31:42 -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 ainOKEtesqi2 for <notmuch@notmuchmail.org>;\r
+ Wed, 4 Dec 2013 08:31:36 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
+ [18.9.25.15])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 55C7F431FC2\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Dec 2013 08:31:36 -0800 (PST)\r
+X-AuditID: 1209190f-b7fb86d000000c36-c1-529f58e75452\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 7F.A6.03126.7E85F925; Wed, 4 Dec 2013 11:31:35 -0500 (EST)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id rB4GVYAN021678; \r
+ Wed, 4 Dec 2013 11:31:35 -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.8/8.12.4) with ESMTP id rB4GVW2d007285\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Wed, 4 Dec 2013 11:31:34 -0500\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1VoFMK-0000cm-GD; Wed, 04 Dec 2013 11:31:32 -0500\r
+Date: Wed, 4 Dec 2013 11:31:32 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jani Nikula <jani@nikula.org>\r
+Subject: Re: [PATCH 1/2] lib: add return status to database close and destroy\r
+Message-ID: <20131204163132.GC8854@mit.edu>\r
+References: <cover.1385903109.git.jani@nikula.org>\r
+ <29b808bb6bf051fe21b6a72f12bb4ad1badfbf97.1385903109.git.jani@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To:\r
+ <29b808bb6bf051fe21b6a72f12bb4ad1badfbf97.1385903109.git.jani@nikula.org>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hTV1n0eMT/IYP49MYum6c4W12/OZHZg\r
+ 8rh1/zW7x7NVt5gDmKK4bFJSczLLUov07RK4MtYuWsFcsEi14tHTO+wNjDtkuxg5OSQETCSa\r
+ 7x1ngbDFJC7cW8/WxcjFISQwm0li4rd1jBDOBkaJlq8HoTKnmCR2Lb3JAuEsYZT4fnAvI0g/\r
+ i4CKxKe/k5lBbDYBDYlt+5eDxUUEFCU2n9wPZjMLSEt8+93MBGILC/hK9L/tAKvnFdCW+Lzi\r
+ NjuILSRQJ3F5/iImiLigxMmZT1ggerUkbvx7CRTnAJuz/B8HSJhTIEzi5b1XYONFgU6YcnIb\r
+ 2wRGoVlIumch6Z6F0L2AkXkVo2xKbpVubmJmTnFqsm5xcmJeXmqRrolebmaJXmpK6SZGcFhL\r
+ 8u9g/HZQ6RCjAAejEg8vB/u8ICHWxLLiytxDjJIcTEqivB3h84OE+JLyUyozEosz4otKc1KL\r
+ DzFKcDArifBODgTK8aYkVlalFuXDpKQ5WJTEeW9y2AcJCaQnlqRmp6YWpBbBZGU4OJQkeMNB\r
+ hgoWpaanVqRl5pQgpJk4OEGG8wAN144AGV5ckJhbnJkOkT/FqCglDtEsAJLIKM2D64WlnVeM\r
+ 4kCvCPMeBKniAaYsuO5XQIOZgAY3P5gHMrgkESEl1cBoy5O64kHBArOSz7orp/Yoyq5YqP7k\r
+ Ca9q3p0kxqeXXOzFX+tJfDR4UnBhl9uaFS+n7590fcGRGa+u7Z+86IlSccqDE+dfl7sL6zo2\r
+ REufcGdeN5HP7Nqd9eqVWxuYQ75V1b5a+tvKQuTiuqS8xsgOnrtNOku59gmv53zV2GN+xlxN\r
+ 6tPhByy/lViKMxINtZiLihMBNAsa9xYDAAA=\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: Wed, 04 Dec 2013 16:31:42 -0000\r
+\r
+Quoth Jani Nikula on Dec 01 at 3:13 pm:\r
+> notmuch_database_close may fail in Xapian ->flush() or ->close(), so\r
+> report the status. Similarly for notmuch_database_destroy which calls\r
+> close.\r
+> \r
+> This is required for notmuch insert to report error status if message\r
+> indexing failed.\r
+> \r
+> Bump the notmuch version to allow clients to conditional build against\r
+> both the current release and the next release (current git master).\r
+> ---\r
+> lib/database.cc | 18 ++++++++++++++----\r
+> lib/notmuch.h | 17 ++++++++++++++---\r
+> 2 files changed, 28 insertions(+), 7 deletions(-)\r
+> \r
+> diff --git a/lib/database.cc b/lib/database.cc\r
+> index f395061..98e2c31 100644\r
+> --- a/lib/database.cc\r
+> +++ b/lib/database.cc\r
+> @@ -767,14 +767,17 @@ notmuch_database_open (const char *path,\r
+> return status;\r
+> }\r
+> \r
+> -void\r
+> +notmuch_status_t\r
+> notmuch_database_close (notmuch_database_t *notmuch)\r
+> {\r
+> + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;\r
+> +\r
+> try {\r
+> if (notmuch->xapian_db != NULL &&\r
+> notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)\r
+> (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();\r
+> } catch (const Xapian::Error &error) {\r
+> + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
+> if (! notmuch->exception_reported) {\r
+> fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",\r
+> error.get_msg().c_str());\r
+> @@ -789,6 +792,7 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
+> notmuch->xapian_db->close();\r
+> } catch (const Xapian::Error &error) {\r
+> /* do nothing */\r
+> + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
+> }\r
+> }\r
+> \r
+> @@ -802,6 +806,8 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
+> notmuch->value_range_processor = NULL;\r
+> delete notmuch->date_range_processor;\r
+> notmuch->date_range_processor = NULL;\r
+> +\r
+> + return status;\r
+> }\r
+> \r
+> #if HAVE_XAPIAN_COMPACT\r
+> @@ -966,7 +972,7 @@ notmuch_database_compact (const char *path,\r
+> \r
+> DONE:\r
+> if (notmuch)\r
+> - notmuch_database_destroy (notmuch);\r
+> + ret = notmuch_database_destroy (notmuch);\r
+\r
+This will clobber the error code on most of the error paths. Maybe\r
+you want to only set ret if it's currently NOTMUCH_STATUS_SUCCESS?\r
+\r
+> \r
+> talloc_free (local);\r
+> \r
+> @@ -984,11 +990,15 @@ notmuch_database_compact (unused (const char *path),\r
+> }\r
+> #endif\r
+> \r
+> -void\r
+> +notmuch_status_t\r
+> notmuch_database_destroy (notmuch_database_t *notmuch)\r
+> {\r
+> - notmuch_database_close (notmuch);\r
+> + notmuch_status_t status;\r
+> +\r
+> + status = notmuch_database_close (notmuch);\r
+> talloc_free (notmuch);\r
+> +\r
+> + return status;\r
+> }\r
+> \r
+> const char *\r
+> diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+> index 7c3a30c..dbdce86 100644\r
+> --- a/lib/notmuch.h\r
+> +++ b/lib/notmuch.h\r
+> @@ -42,7 +42,7 @@ NOTMUCH_BEGIN_DECLS\r
+> #endif\r
+> \r
+> #define NOTMUCH_MAJOR_VERSION 0\r
+> -#define NOTMUCH_MINOR_VERSION 17\r
+> +#define NOTMUCH_MINOR_VERSION 18\r
+> #define NOTMUCH_MICRO_VERSION 0\r
+\r
+This is actually what got me thinking about\r
+id:1386173986-9624-1-git-send-email-amdragon@mit.edu (which obviously\r
+conflicts). In particular, the Python bindings don't have access to\r
+these macros, and can only use the soname version. (I think the Go\r
+ones can use the macros; the Ruby ones certainly can.)\r
+\r
+> \r
+> /*\r
+> @@ -236,8 +236,16 @@ notmuch_database_open (const char *path,\r
+> *\r
+> * notmuch_database_close can be called multiple times. Later calls\r
+> * have no effect.\r
+> + *\r
+> + * Return value:\r
+> + *\r
+> + * NOTMUCH_STATUS_SUCCESS: Successfully closed the database.\r
+> + *\r
+> + * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; the\r
+> + * database has been closed but there are no guarantees the\r
+> + * changes to the database, if any, have been flushed to disk.\r
+> */\r
+> -void\r
+> +notmuch_status_t\r
+> notmuch_database_close (notmuch_database_t *database);\r
+> \r
+> /* A callback invoked by notmuch_database_compact to notify the user\r
+> @@ -263,8 +271,11 @@ notmuch_database_compact (const char* path,\r
+> \r
+> /* Destroy the notmuch database, closing it if necessary and freeing\r
+> * all associated resources.\r
+> + *\r
+> + * Return value as in notmuch_database_close if the database was open;\r
+> + * notmuch_database_destroy itself has no failure modes.\r
+> */\r
+> -void\r
+> +notmuch_status_t\r
+> notmuch_database_destroy (notmuch_database_t *database);\r
+> \r
+> /* Return the database path of the given database.\r
+\r
+Regarding bindings (since you asked me to think about them), these\r
+should be a safe changes from an ABI perspective (though obviously the\r
+bindings will need changes to take advantage of the new return code).\r