--- /dev/null
+Return-Path: <teythoon@jade-hamburg.de>\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 298D5429E2F\r
+ for <notmuch@notmuchmail.org>; Tue, 20 Mar 2012 17:55:43 -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 UfLuSSTHAivk for <notmuch@notmuchmail.org>;\r
+ Tue, 20 Mar 2012 17:55:40 -0700 (PDT)\r
+Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 92FAA431FD7\r
+ for <notmuch@notmuchmail.org>; Tue, 20 Mar 2012 17:55:36 -0700 (PDT)\r
+Received: from mail.jade-hamburg.de (unknown [85.183.11.228])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by mail.cryptobitch.de (Postfix) with ESMTPSA id 2232457678E\r
+ for <notmuch@notmuchmail.org>; Wed, 21 Mar 2012 01:55:35 +0100 (CET)\r
+Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
+ id 941C5DF2A2; Wed, 21 Mar 2012 01:55:34 +0100 (CET)\r
+Received: from thinkbox.jade-hamburg.de (unknown [10.1.1.153])\r
+ (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+ (No client certificate requested) (Authenticated sender: teythoon)\r
+ by mail.jade-hamburg.de (Postfix) with ESMTPSA id 16847DF2A1;\r
+ Wed, 21 Mar 2012 01:55:26 +0100 (CET)\r
+Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77)\r
+ (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
+ id 1SA9pk-0007v7-8t; Wed, 21 Mar 2012 01:55:24 +0100\r
+From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/7] Split notmuch_database_close into two functions\r
+Date: Wed, 21 Mar 2012 01:55:05 +0100\r
+Message-Id:\r
+ <1332291311-28954-2-git-send-email-4winter@informatik.uni-hamburg.de>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To:\r
+ <1332291311-28954-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+References:\r
+ <1332291311-28954-1-git-send-email-4winter@informatik.uni-hamburg.de>\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, 21 Mar 2012 00:55:43 -0000\r
+\r
+Formerly notmuch_database_close closed the xapian database and\r
+destroyed the talloc structure associated with the notmuch database\r
+object. Split notmuch_database_close into notmuch_database_close and\r
+notmuch_database_destroy.\r
+\r
+This makes it possible for long running programs to close the xapian\r
+database and thus release the lock associated with it without\r
+destroying the data structures obtained from it.\r
+\r
+This also makes the api more consistent since every other data\r
+structure has a destructor function.\r
+\r
+Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+---\r
+ lib/database.cc | 14 ++++++++++++--\r
+ lib/notmuch.h | 15 +++++++++++----\r
+ 2 files changed, 23 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 16c4354..2fefcad 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -642,7 +642,7 @@ notmuch_database_open (const char *path,\r
+ " read-write mode.\n",\r
+ notmuch_path, version, NOTMUCH_DATABASE_VERSION);\r
+ notmuch->mode = NOTMUCH_DATABASE_MODE_READ_ONLY;\r
+- notmuch_database_close (notmuch);\r
++ notmuch_database_destroy (notmuch);\r
+ notmuch = NULL;\r
+ goto DONE;\r
+ }\r
+@@ -702,7 +702,7 @@ notmuch_database_open (const char *path,\r
+ } catch (const Xapian::Error &error) {\r
+ fprintf (stderr, "A Xapian exception occurred opening database: %s\n",\r
+ error.get_msg().c_str());\r
+- notmuch_database_close (notmuch);\r
++ notmuch_database_destroy (notmuch);\r
+ notmuch = NULL;\r
+ }\r
+ \r
+@@ -738,9 +738,19 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
+ }\r
+ \r
+ delete notmuch->term_gen;\r
++ notmuch->term_gen = NULL;\r
+ delete notmuch->query_parser;\r
++ notmuch->query_parser = NULL;\r
+ delete notmuch->xapian_db;\r
++ notmuch->xapian_db = NULL;\r
+ delete notmuch->value_range_processor;\r
++ notmuch->value_range_processor = NULL;\r
++}\r
++\r
++void\r
++notmuch_database_destroy (notmuch_database_t *notmuch)\r
++{\r
++ notmuch_database_close (notmuch);\r
+ talloc_free (notmuch);\r
+ }\r
+ \r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index babd208..6114f36 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -133,7 +133,7 @@ typedef struct _notmuch_filenames notmuch_filenames_t;\r
+ *\r
+ * After a successful call to notmuch_database_create, the returned\r
+ * database will be open so the caller should call\r
+- * notmuch_database_close when finished with it.\r
++ * notmuch_database_destroy when finished with it.\r
+ *\r
+ * The database will not yet have any data in it\r
+ * (notmuch_database_create itself is a very cheap function). Messages\r
+@@ -165,7 +165,7 @@ typedef enum {\r
+ * An existing notmuch database can be identified by the presence of a\r
+ * directory named ".notmuch" below 'path'.\r
+ *\r
+- * The caller should call notmuch_database_close when finished with\r
++ * The caller should call notmuch_database_destroy when finished with\r
+ * this database.\r
+ *\r
+ * In case of any failure, this function returns NULL, (after printing\r
+@@ -175,11 +175,18 @@ notmuch_database_t *\r
+ notmuch_database_open (const char *path,\r
+ notmuch_database_mode_t mode);\r
+ \r
+-/* Close the given notmuch database, freeing all associated\r
+- * resources. See notmuch_database_open. */\r
++/* Close the given notmuch database.\r
++ *\r
++ * This function is called by notmuch_database_destroyed and can be\r
++ * called multiple times. */\r
+ void\r
+ notmuch_database_close (notmuch_database_t *database);\r
+ \r
++/* Destroy the notmuch database freeing all associated\r
++ * resources */\r
++void\r
++notmuch_database_destroy (notmuch_database_t *database);\r
++\r
+ /* Return the database path of the given database.\r
+ *\r
+ * The return value is a string owned by notmuch so should not be\r
+-- \r
+1.7.9.1\r
+\r