--- /dev/null
+Return-Path: <jani@nikula.org>\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 B2ED9431E64\r
+ for <notmuch@notmuchmail.org>; Sun, 1 Dec 2013 05:14:17 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\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 qtChdgI-2GrN for <notmuch@notmuchmail.org>;\r
+ Sun, 1 Dec 2013 05:14:11 -0800 (PST)\r
+Received: from mail-ea0-f173.google.com (mail-ea0-f173.google.com\r
+ [209.85.215.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id B924A431FD2\r
+ for <notmuch@notmuchmail.org>; Sun, 1 Dec 2013 05:14:10 -0800 (PST)\r
+Received: by mail-ea0-f173.google.com with SMTP id g15so8110033eak.32\r
+ for <notmuch@notmuchmail.org>; Sun, 01 Dec 2013 05:14:09 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=2xbixmUduEMNU21MNDaUNJtjM1jmJTHMq8SMNSGFs6k=;\r
+ b=bsym/N1zM163VS7HdiApv7nBhxUCzrsfjlClJJl3dEKbbc4ZAttY19gOxGmVvkL+MD\r
+ zq/RiitSUaHkUbnmxAwdNlZ5ELcREY1GA9bfFr8COpoNybhmJHon9ZMLhHuCLmQYdhEa\r
+ IxRPNSligqHumreF13qGQ0/J+dSvQUpDi7daHAoXJDmQUiWGc0vckbnvbiCVO3QRaoz5\r
+ /nVgxlrjxal7hRMexEoupUbh3LYZpyq+O2CnpW3knHwn2Ef13xEQuYE0Un9W98PSCGr0\r
+ fTdgLs3NjKW8/MgvhNe4kO7l4YXB7ceHanrMJ39moLGKQn4ag53ln7/E7aCRXUChbRnK\r
+ KhXQ==\r
+X-Gm-Message-State:\r
+ ALoCoQkfpFejya4ordClciAPPdElX83mNjHCKXJlCRcsEjUikWYscNOjFxo+ha80bj2H3zZji2V8\r
+X-Received: by 10.14.3.130 with SMTP id 2mr27384452eeh.36.1385903649638;\r
+ Sun, 01 Dec 2013 05:14:09 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91]) by mx.google.com with ESMTPSA id\r
+ b41sm37212095eef.16.2013.12.01.05.14.07 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 01 Dec 2013 05:14:09 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] lib: add return status to database close and destroy\r
+Date: Sun, 1 Dec 2013 15:13:59 +0200\r
+Message-Id:\r
+ <29b808bb6bf051fe21b6a72f12bb4ad1badfbf97.1385903109.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.4.2\r
+In-Reply-To: <cover.1385903109.git.jani@nikula.org>\r
+References: <cover.1385903109.git.jani@nikula.org>\r
+In-Reply-To: <cover.1385903109.git.jani@nikula.org>\r
+References: <cover.1385903109.git.jani@nikula.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: Sun, 01 Dec 2013 13:14:18 -0000\r
+\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
+ 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
+ /*\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
+1.8.4.2\r
+\r