--- /dev/null
+Return-Path: <adrien@bustany.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 06E6B431FC4\r
+ for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 14:52:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 TdOMsd1PTqUk for <notmuch@notmuchmail.org>;\r
+ Wed, 17 Oct 2012 14:52:39 -0700 (PDT)\r
+Received: from mail.bustany.org (bustany.org [176.31.244.208])\r
+ by olra.theworths.org (Postfix) with ESMTP id D48CC431FBD\r
+ for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 14:52:38 -0700 (PDT)\r
+Received: from localhost.localdomain (91-158-5-86.elisa-laajakaista.fi\r
+ [91.158.5.86])\r
+ by mail.bustany.org (Postfix) with ESMTPSA id 319321401ED\r
+ for <notmuch@notmuchmail.org>; Wed, 17 Oct 2012 23:56:26 +0200 (CEST)\r
+From: Adrien Bustany <adrien@bustany.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] Add notmuch_database_reopen method\r
+Date: Thu, 18 Oct 2012 00:52:22 +0300\r
+Message-Id: <1350510742-13447-3-git-send-email-adrien@bustany.org>\r
+X-Mailer: git-send-email 1.7.11.7\r
+In-Reply-To: <1350510742-13447-1-git-send-email-adrien@bustany.org>\r
+References: <1342723401-26103-1-git-send-email-adrien@bustany.org>\r
+ <1350510742-13447-1-git-send-email-adrien@bustany.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, 17 Oct 2012 21:52:40 -0000\r
+\r
+Calling notmuch_database_reopen is needed to refresh the database\r
+contents when the database on disk was modified by another\r
+notmuch_database_t instance, for example in a different thread.\r
+---\r
+ lib/database.cc | 17 +++++++++++++++++\r
+ lib/notmuch.h | 8 ++++++++\r
+ 2 files changed, 25 insertions(+)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 1b680ab..f27d57f 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -763,6 +763,23 @@ notmuch_database_flush(notmuch_database_t *notmuch)\r
+ return status;\r
+ }\r
+ \r
++notmuch_status_t\r
++notmuch_database_reopen(notmuch_database_t *notmuch)\r
++{\r
++ notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;\r
++\r
++ try {\r
++ if (notmuch->xapian_db != NULL)\r
++ (notmuch->xapian_db)->reopen ();\r
++ } catch (const Xapian::Error &error) {\r
++ fprintf(stderr, "A Xapian exception occured reopening the database: %s\n",\r
++ error.get_msg().c_str());\r
++ status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
++ }\r
++\r
++ return status;\r
++}\r
++\r
+ void\r
+ notmuch_database_close (notmuch_database_t *notmuch)\r
+ {\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index aef5c56..51d6a9a 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -205,6 +205,14 @@ notmuch_database_open (const char *path,\r
+ notmuch_status_t\r
+ notmuch_database_flush (notmuch_database_t *database);\r
+ \r
++/* Refresh the database contents to the latest version.\r
++ *\r
++ * This is needed only if another instance of notmuch_database_t has\r
++ * modified the database contents on disk.\r
++ */\r
++notmuch_status_t\r
++notmuch_database_reopen (notmuch_database_t *database);\r
++\r
+ /* Close the given notmuch database.\r
+ *\r
+ * After notmuch_database_close has been called, calls to other\r
+-- \r
+1.7.11.7\r
+\r