--- /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 C5C22431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 22 Apr 2012 11:02:03 -0700 (PDT)\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 QFfdyK8LYcYD for <notmuch@notmuchmail.org>;\r
+ Sun, 22 Apr 2012 11:02:03 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+ [18.9.25.14])\r
+ by olra.theworths.org (Postfix) with ESMTP id D1BDD431FAE\r
+ for <notmuch@notmuchmail.org>; Sun, 22 Apr 2012 11:02:02 -0700 (PDT)\r
+X-AuditID: 1209190e-b7f7c6d0000008c3-7d-4f94479a17a2\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 0C.D7.02243.A97449F4; Sun, 22 Apr 2012 14:02:02 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q3MI21HZ001500; \r
+ Sun, 22 Apr 2012 14:02:01 -0400\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.6/8.12.4) with ESMTP id q3MI20Lu018743\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Sun, 22 Apr 2012 14:02:01 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1SM16l-0007z8-Qy; Sun, 22 Apr 2012 14:01:59 -0400\r
+Date: Sun, 22 Apr 2012 14:01:59 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+Subject: Re: [PATCH 1/7] Split notmuch_database_close into two functions\r
+Message-ID: <20120422180159.GG17810@mit.edu>\r
+References: <20120422120620.26225.40778@thinkbox.jade-hamburg.de>\r
+ <1335096477-27537-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To:\r
+ <1335096477-27537-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IRYrdT153lPsXf4P5jaYvZrT+YLK7fnMns\r
+ wOQx8fxpNo9nq24xBzBFcdmkpOZklqUW6dslcGVMXHiateCXasWk491MDYyT5boYOTkkBEwk\r
+ 7jXOY4WwxSQu3FvP1sXIxSEksI9RonFeExNIQkhgA6PEp/lQiZNMEif75jJDOEsYJX79WsYO\r
+ UsUioCqx6OwERhCbTUBDYtv+5WC2iICpxIYHD8BqmAWkJb79bgabKizgIbHj2h6wGl4BHYkJ\r
+ h7qYIIZ2Mko8+L+TBSIhKHFy5hMWiGYtiRv/XgIVcYANWv6PAyTMKRAksXZ1I9gcUQEViSkn\r
+ t7FNYBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFuka6+VmluilppRuYgQF\r
+ Nqck3w7GrweVDjEKcDAq8fA6mU/2F2JNLCuuzD3EKMnBpCTK+9ptir8QX1J+SmVGYnFGfFFp\r
+ TmrxIUYJDmYlEd7PIkDlvCmJlVWpRfkwKWkOFiVxXjWtd35CAumJJanZqakFqUUwWRkODiUJ\r
+ XjNgBAsJFqWmp1akZeaUIKSZODhBhvMADf8Ospi3uCAxtzgzHSJ/ilFRSpxXA6RZACSRUZoH\r
+ 1wtLPK8YxYFeEeYVB6niASYtuO5XQIOZgAYnxEwCGVySiJCSamAUe7loa9uv/LnnK6ZsPb7p\r
+ 1YS5Jpt6kkR7OT5NdV0wYW3h3ICQi221WzY3Sf33Fpu6MvFhceadJVoycVwMbceFzWcG64u/\r
+ 0bmQefzh/pnct4sCqxsPRSfI+C/NObnnxRl+KfU1p/P9ghW2Xfu35ZHaTMeWteymu6a6HhYN\r
+ Otq2fzaLS45v4xJbJZbijERDLeai4kQAPp2AphcDAAA=\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: Sun, 22 Apr 2012 18:02:03 -0000\r
+\r
+Quoth Justus Winter on Apr 22 at 2:07 pm:\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 673c423..84c9265 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_destroy and can be\r
+> + * called multiple times. */\r
+\r
+This needs a comment explaining the implications of closing the\r
+database. Perhaps something like this (modeled on\r
+Xapian::Database::close's documentation)\r
+\r
+/* Close the given notmuch database.\r
+ *\r
+ * After notmuch_database_close has been called, calls to other\r
+ * functions on objects derived from this database may either behave\r
+ * as if the database had not been closed (e.g., if the required data\r
+ * has been cached) or may fail with a\r
+ * NOTMUCH_STATUS_XAPIAN_EXCEPTION.\r
+ *\r
+ * notmuch_database_close can be called multiple times. Later calls\r
+ * have no affect. \r
+ */\r
+\r
+> void\r
+> notmuch_database_close (notmuch_database_t *database);\r
+> \r
+> +/* Destroy the notmuch database freeing all associated\r
+> + * resources */\r
+\r
+This should mention that this also closes the database (currently you\r
+mention this in the doc for notmuch_database_close, but it's a reverse\r
+reference there; that could probably even be omitted). Perhaps\r
+\r
+/* Destroy the notmuch database, closing it if necessary and freeing\r
+ * all associated resources. */\r
+\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