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