--- /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 09437431FD2\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Dec 2013 10:40:47 -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 MgAPnpA6ZwOR for <notmuch@notmuchmail.org>;\r
+ Wed, 4 Dec 2013 10:40:39 -0800 (PST)\r
+Received: from mail-qe0-f53.google.com (mail-qe0-f53.google.com\r
+ [209.85.128.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 81F7B431FD0\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Dec 2013 10:40:39 -0800 (PST)\r
+Received: by mail-qe0-f53.google.com with SMTP id nc12so14632638qeb.40\r
+ for <notmuch@notmuchmail.org>; Wed, 04 Dec 2013 10:40:39 -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:in-reply-to:references\r
+ :user-agent:date:message-id:mime-version:content-type;\r
+ bh=H3AnR/WHVt9NqSYD2Xsm24B7qu1fT96IxNbbgD2Iuvs=;\r
+ b=J7Pg+drn/5r3oRflblzLM0w4eS5Bw37kSDhG782GLoSJeogBUMPF3JDhD6yW4eHe7Q\r
+ +v2KBnQNWIdEo1RBUwjgxGz1QKXkSJbSIT1xl7WmiqckasMvFUi8OE+6myXnzMmJ9Jo6\r
+ VZhXgYQRGp6oGaFwKIk3DHlSDsZT/kagZM+oMVcQTShwOYef4VppdyUNOyv4K2Mkua+p\r
+ +R+7HY1dmeOUxjO0SWSJCfCJkuvnP7AG7YZsdqbhzNl0j6fBDxfwiUfVQS1om7FeaSL9\r
+ CUTtVlkn7d/JjHE4uXlQ9GInd6uBQUKQ5WEs9jNvK7rrXfwecxnCAubZEA9i3YJMqlNc\r
+ bFMQ==\r
+X-Gm-Message-State:\r
+ ALoCoQlByi/hNkAMF3+cPcbjZrKoNff0LtMMLMrkONRF+2OhYFADob6sisC5t6nbWk/QRoDyMU6W\r
+X-Received: by 10.224.75.200 with SMTP id z8mr138784229qaj.71.1386182438919;\r
+ Wed, 04 Dec 2013 10:40:38 -0800 (PST)\r
+Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
+ by mx.google.com with ESMTPSA id hb2sm20160543qeb.6.2013.12.04.10.40.38\r
+ for <multiple recipients>\r
+ (version=TLSv1.1 cipher=RC4-SHA bits=128/128);\r
+ Wed, 04 Dec 2013 10:40:38 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Austin Clements <amdragon@MIT.EDU>\r
+Subject: Re: [PATCH 1/2] lib: add return status to database close and destroy\r
+In-Reply-To: <20131204163132.GC8854@mit.edu>\r
+References: <cover.1385903109.git.jani@nikula.org>\r
+ <29b808bb6bf051fe21b6a72f12bb4ad1badfbf97.1385903109.git.jani@nikula.org>\r
+ <20131204163132.GC8854@mit.edu>\r
+User-Agent: Notmuch/0.17~rc2+4~gd7b0a0a (http://notmuchmail.org) Emacs/23.2.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Wed, 04 Dec 2013 19:40:19 +0100\r
+Message-ID: <87ob4wsbn0.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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 18:40:47 -0000\r
+\r
+On Wed, 04 Dec 2013, Austin Clements <amdragon@MIT.EDU> wrote:\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
+Good point, will fix.\r
+\r
+BR,\r
+Jani.\r
+\r
+\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