Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 41000431FAF for ; Mon, 16 Apr 2012 09:02:25 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 mXFOOorU5EBg for ; Mon, 16 Apr 2012 09:02:23 -0700 (PDT) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 19E05431FAE for ; Mon, 16 Apr 2012 09:02:23 -0700 (PDT) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1SJoNe-0003iz-0Y; Mon, 16 Apr 2012 17:02:20 +0100 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1SJoNd-0005ct-IM; Mon, 16 Apr 2012 17:02:17 +0100 From: Mark Walters To: Austin Clements , notmuch@notmuchmail.org Subject: Re: [PATCH 2/3] new: Handle fatal errors in remove_filename and _remove_directory In-Reply-To: <1330357759-1337-3-git-send-email-amdragon@mit.edu> References: <1330357759-1337-1-git-send-email-amdragon@mit.edu> <1330357759-1337-3-git-send-email-amdragon@mit.edu> User-Agent: Notmuch/0.12+110~gbc97b4a (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Mon, 16 Apr 2012 17:02:37 +0100 Message-ID: <87wr5f4qci.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 94.192.233.223 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: 5eaeadecc221fe0613c546ee760dc5a3 (of first 20000 bytes) X-SpamAssassin-Score: -1.8 X-SpamAssassin-SpamBar: - X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -1.8 points. Summary of the scoring: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [138.37.6.40 listed in list.dnswl.org] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay * domain * 0.5 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Mon, 16 Apr 2012 16:02:25 -0000 On Mon, 27 Feb 2012, Austin Clements wrote: > Previously such errors were simply ignored. Now they cause an > immediate cleanup and abort. This one looks fine except for a minor query. > --- > notmuch-new.c | 24 ++++++++++++++++++------ > 1 files changed, 18 insertions(+), 6 deletions(-) > > diff --git a/notmuch-new.c b/notmuch-new.c > index bd9786a..0cbd479 100644 > --- a/notmuch-new.c > +++ b/notmuch-new.c > @@ -780,8 +780,10 @@ remove_filename (notmuch_database_t *notmuch, > add_files_state->renamed_messages++; > if (add_files_state->synchronize_flags == TRUE) > notmuch_message_maildir_flags_to_tags (message); > - } else > + status = NOTMUCH_STATUS_SUCCESS; > + } else if (status == NOTMUCH_STATUS_SUCCESS) { > add_files_state->removed_messages++; > + } > notmuch_message_destroy (message); > notmuch_database_end_atomic (notmuch); > return status; > @@ -789,12 +791,13 @@ remove_filename (notmuch_database_t *notmuch, > > /* Recursively remove all filenames from the database referring to > * 'path' (or to any of its children). */ > -static void > +static notmuch_status_t > _remove_directory (void *ctx, > notmuch_database_t *notmuch, > const char *path, > add_files_state_t *add_files_state) > { > + notmuch_status_t status; > notmuch_directory_t *directory; > notmuch_filenames_t *files, *subdirs; > char *absolute; > @@ -807,8 +810,10 @@ _remove_directory (void *ctx, > { > absolute = talloc_asprintf (ctx, "%s/%s", path, > notmuch_filenames_get (files)); > - remove_filename (notmuch, absolute, add_files_state); > + status = remove_filename (notmuch, absolute, add_files_state); > talloc_free (absolute); > + if (status) > + return status; > } > > for (subdirs = notmuch_directory_get_child_directories (directory); > @@ -817,11 +822,14 @@ _remove_directory (void *ctx, > { > absolute = talloc_asprintf (ctx, "%s/%s", path, > notmuch_filenames_get (subdirs)); > - _remove_directory (ctx, notmuch, absolute, add_files_state); > + status = _remove_directory (ctx, notmuch, absolute, add_files_state); > talloc_free (absolute); > + if (status) > + return status; > } > > notmuch_directory_destroy (directory); > + return NOTMUCH_STATUS_SUCCESS; > } In the two "return status" lines above seem to mean we don't call notmuch_directory_destroy. Does that matter? The other query is not actually about this patch: just something that came up when reading it. Should notmuch_database_begin_atomic and notmuch_database_end_atomic always be paired? One of the (existing) error cases in remove_filename seems to return without calling end. Best wishes Mark > int > @@ -939,7 +947,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) > > gettimeofday (&tv_start, NULL); > for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) { > - remove_filename (notmuch, f->filename, &add_files_state); > + ret = remove_filename (notmuch, f->filename, &add_files_state); > + if (ret) > + goto DONE; > if (do_print_progress) { > do_print_progress = 0; > generic_print_progress ("Cleaned up", "messages", > @@ -950,7 +960,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) > > gettimeofday (&tv_start, NULL); > for (f = add_files_state.removed_directories->head, i = 0; f && !interrupted; f = f->next, i++) { > - _remove_directory (ctx, notmuch, f->filename, &add_files_state); > + ret = _remove_directory (ctx, notmuch, f->filename, &add_files_state); > + if (ret) > + goto DONE; > if (do_print_progress) { > do_print_progress = 0; > generic_print_progress ("Cleaned up", "directories", > -- > 1.7.7.3 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch