[RFC PATCH 11/13] Add a close function to mailstore
authorEthan Glasser-Camp <glasse@cs.rpi.edu>
Wed, 15 Feb 2012 22:02:04 +0000 (17:02 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:34 +0000 (09:44 -0800)
2b/6dfc5ce0590508e4b28c73a24bdf24d4eb0d46 [new file with mode: 0644]

diff --git a/2b/6dfc5ce0590508e4b28c73a24bdf24d4eb0d46 b/2b/6dfc5ce0590508e4b28c73a24bdf24d4eb0d46
new file mode 100644 (file)
index 0000000..402be7c
--- /dev/null
@@ -0,0 +1,160 @@
+Return-Path: <glasse@cs.rpi.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 B478F431E82\r
+       for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:12:36 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.54\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.54 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       RCVD_IN_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_MED=-2.3,\r
+       RCVD_IN_SORBS_WEB=0.614] 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 YiUerY5Aj4f0 for <notmuch@notmuchmail.org>;\r
+       Wed, 15 Feb 2012 14:12:35 -0800 (PST)\r
+Received: from cliffclavin.cs.rpi.edu (cliffclavin.cs.rpi.edu\r
+ [128.113.126.25])     (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)       by olra.theworths.org (Postfix) with ESMTPS\r
+ id 29B33431E62        for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:12:35 -0800\r
+ (PST)\r
+X-Hash:\r
+ S|91de1c178376ed50903de0e611ee3c2e43cd0ccf|2c8ecd09f629f4b4d3170c072856d3da\r
+X-Countries: Cameroon, United States\r
+X-SMTP-From: accepted <glasse@cs.rpi.edu> [195.24.209.20] [195.24.209.20]\r
+       (localhost) {Cameroon}\r
+DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cs.rpi.edu; h=from\r
+       :to:cc:subject:date:message-id:in-reply-to:references; s=\r
+       default; i=glasse@cs.rpi.edu; t=1329343952; x=1329948752; l=2737;\r
+       bh=Uq4pkiIyt5pJMHHl0sUA9WUPngU=; b=VPZk8SIWjcxsYrmJE9nWdS7\r
+       Cl5iR+g5lXObJpZiOu7KnMhdfVJIsryzceuAK/PO1xUQ8rdrUQVP8QIpxwxWhe4x\r
+       Xf/Fj1GvrMP4hnY6bDAIcDoR4gNDRxiE56TbMZ6zHQ1DQhSYU1Du9dy229wESEMq\r
+       UB1roaWCWj1y2b6/JvIA=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=cs.rpi.edu; h=from:to:cc\r
+       :subject:date:message-id:in-reply-to:references; q=dns; s=\r
+       default; b=oYB+8Flt9fGRaFPrt62cIbDsbmPG/HPHODwp/wrKtYAUkCKGhRAnp\r
+       tyyfHHisw9y3PkOM8L6TvYm0B0iQdxFUSeX8vB2GFlfoYFynIIOKOcZMEvFtoY09\r
+       HuFB6vc6w+TVEpm++2LOYWx7lx1Mri9HdOISVa6dao8FnECwuOoVOs=\r
+X-Spam-Info: -2.7; ALL_TRUSTED,AWL,BAYES_00\r
+X-Spam-Scanned-By: cliffclavin.cs.rpi.edu using SpamAssassin 3.2.5 (hard limit\r
+       15)\r
+Authentication-Results: cliffclavin.cs.rpi.edu;\r
+       DKIM=neutral (none) header.from=glasse@cs.rpi.edu;\r
+       SPF=neutral (mfrom;\r
+       Mechanism '?all' matched) smtp.mail=glasse@cs.rpi.edu\r
+X-Auth-Passed: cliffclavin.cs.rpi.edu:q1FMCBqp008866 Auth:glasse\r
+X-Virus-Scanned-By: cliffclavin.cs.rpi.edu\r
+Received: from localhost ([195.24.209.20]) (authenticated bits=0)\r
+       by cliffclavin.cs.rpi.edu (8.14.3/8.14.3) with ESMTP id q1FMCBqp008866\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);\r
+       Wed, 15 Feb 2012 17:12:24 -0500 (EST)\r
+       (envelope-from glasse@cs.rpi.edu)\r
+From: Ethan Glasser-Camp <glasse@cs.rpi.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH 11/13] Add a close function to mailstore\r
+Date: Wed, 15 Feb 2012 17:02:04 -0500\r
+Message-Id: <1329343326-16410-12-git-send-email-glasse@cs.rpi.edu>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>\r
+References: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>\r
+X-Scanned-By: MIMEDefang 2.67 on 128.113.126.25\r
+Cc: Ethan Glasser-Camp <ethan@betacantrips.com>\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, 15 Feb 2012 22:12:36 -0000\r
+\r
+From: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+\r
+This is a useful way to signal to mailstores that the resources\r
+associated with an existing FILE* are no longer being used and they\r
+can be cleaned up. For maildir, of course, this is just a call to\r
+fclose(), but for other mailstores this might involve freeing memory\r
+or unlinking temporary files...\r
+\r
+Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+---\r
+ lib/mailstore.c |   17 ++++++++++++++++-\r
+ lib/notmuch.h   |    5 +++++\r
+ 2 files changed, 21 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/lib/mailstore.c b/lib/mailstore.c\r
+index b4d512d..51c2710 100644\r
+--- a/lib/mailstore.c\r
++++ b/lib/mailstore.c\r
+@@ -24,6 +24,7 @@\r
+ typedef struct _notmuch_mailstore {\r
+     notmuch_status_t (*constructor) (void **data, va_list args);\r
+     FILE *(*open) (struct _notmuch_mailstore *mailstore, const char *filename);\r
++    int (*close) (struct _notmuch_mailstore *mailstore, FILE *);\r
+     int (*rename) (struct _notmuch_mailstore *mailstore, const char *old_filename,\r
+                  const char *new_filename);\r
+     void *data;\r
+@@ -44,6 +45,13 @@ _maildir_open_function (unused (notmuch_mailstore_t *mailstore),\r
+ }\r
\r
+ static int\r
++_maildir_close_function (unused (notmuch_mailstore_t *mailstore),\r
++                       FILE *file)\r
++{\r
++    return fclose (file);\r
++}\r
++\r
++static int\r
+ _maildir_rename_function (unused (notmuch_mailstore_t *mailstore),\r
+                         const char *old_filename, const char *new_filename)\r
+ {\r
+@@ -68,7 +76,8 @@ _maildir_rename_function (unused (notmuch_mailstore_t *mailstore),\r
+  */\r
+ _notmuch_mailstore\r
+ notmuch_mailstore_maildir = { _maildir_constructor,\r
+-                            _maildir_open_function, _maildir_rename_function,\r
++                            _maildir_open_function, _maildir_close_function,\r
++                            _maildir_rename_function,\r
+                             NULL };\r
\r
+ _notmuch_mailstore *\r
+@@ -93,6 +102,12 @@ notmuch_mailstore_rename (notmuch_mailstore_t *mailstore, const char *old_filena\r
+     return mailstore->rename (mailstore, old_filename, new_filename);\r
+ }\r
\r
++int\r
++notmuch_mailstore_close (notmuch_mailstore_t *mailstore, FILE *file)\r
++{\r
++    return mailstore->close (mailstore, file);\r
++}\r
++\r
+ notmuch_status_t\r
+ notmuch_mailstore_construct (notmuch_mailstore_t *mailstore, ...)\r
+ {\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index 7f48507..d760d4f 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -423,6 +423,11 @@ notmuch_mailstore_get_by_name (const char *name);\r
+ FILE *\r
+ notmuch_mailstore_open (notmuch_mailstore_t *mailstore, const char *filename);\r
\r
++/* Signal that a filename is no longer being used; get rid of its resources.\r
++ */\r
++int\r
++notmuch_mailstore_close (notmuch_mailstore_t *mailstore, FILE *file);\r
++\r
+ /* Rename a file. This is used to update maildir tags and can safely\r
+  * be a NO-OP for non-filesystem mailstores.\r
+  */\r
+-- \r
+1.7.5.4\r
+\r