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 BECCD431FAF for ; Sun, 22 Apr 2012 08:36:22 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 46QNNYjeAnQA for ; Sun, 22 Apr 2012 08:36:20 -0700 (PDT) Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by olra.theworths.org (Postfix) with ESMTP id 6C896431FAE for ; Sun, 22 Apr 2012 08:36:20 -0700 (PDT) X-AuditID: 1209190f-b7f8a6d000000914-7d-4f94257355da Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id 9B.57.02324.375249F4; Sun, 22 Apr 2012 11:36:19 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q3MFaI8u017529; Sun, 22 Apr 2012 11:36:19 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3MFaHQB002459 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 22 Apr 2012 11:36:17 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1SLypl-0007aF-24; Sun, 22 Apr 2012 11:36:17 -0400 Date: Sun, 22 Apr 2012 11:36:17 -0400 From: Austin Clements To: Mark Walters Subject: Re: [PATCH v2 2/4] new: Handle fatal errors in remove_filename and _remove_directory Message-ID: <20120422153617.GE17810@mit.edu> References: <1330357759-1337-1-git-send-email-amdragon@mit.edu> <1335068868-12593-1-git-send-email-amdragon@mit.edu> <1335068868-12593-3-git-send-email-amdragon@mit.edu> <87aa24kyog.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87aa24kyog.fsf@qmul.ac.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IR4hTV1i1WneJvcPw1h8XquTwW12/OZHZg 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4MpaeOMBS8Eek4smCv2wNjJMFuhg5OSQETCRu 9JxkhLDFJC7cW8/WxcjFISSwj1FictsidghnA6PE9D1PGSGck0wSM8/dZ4JwljBKPF52lg2k n0VAVeLu8gUsIDabgIbEtv3LweaKCOhI3D60gB3EZhaQlvj2u5kJxBYWiJf4efk9WA0vUM3G i9eh1p1mlPjzdx87REJQ4uTMJywQzVoSN/69BGrmABu0/B8HSJgTaNeZE/fAykUFVCSmnNzG NoFRaBaS7llIumchdC9gZF7FKJuSW6Wbm5iZU5yarFucnJiXl1qka6KXm1mil5pSuokRHNiS /DsYvx1UOsQowMGoxMP7ymSyvxBrYllxZe4hRkkOJiVRXi+lKf5CfEn5KZUZicUZ8UWlOanF hxglOJiVRHg/iwCV86YkVlalFuXDpKQ5WJTEedW03vkJCaQnlqRmp6YWpBbBZGU4OJQkeNeq AA0VLEpNT61Iy8wpQUgzcXCCDOcBGr4BpIa3uCAxtzgzHSJ/ilFRSpx3I0hCACSRUZoH1wtL PK8YxYFeEeY9D1LFA0xacN2vgAYzAQ1OiJkEMrgkESEl1cC4MPiWkU7h+5TO3y8rPh+ddPOn /AJzb8+s0x0s1qZN06Pql81S6dd6Wrbd3Ox81c4dT084P3UsNgvYbPJa2fXsjlXVP3l7T/7X rJnkUrp/hzrL4Vle3r/kWWv1Zl7327Op4QKz/NRFM90//ufrlPtatoshrCvOU9zeU2h5TXHG cnav97yv9zorsRRnJBpqMRcVJwIAFpHCcxcDAAA= Cc: notmuch@notmuchmail.org 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: Sun, 22 Apr 2012 15:36:22 -0000 Quoth Mark Walters on Apr 22 at 8:34 am: > On Sun, 22 Apr 2012, Austin Clements wrote: > > Previously such errors were simply ignored. Now they cause an > > immediate cleanup and abort. > > --- > > notmuch-new.c | 25 +++++++++++++++++++------ > > 1 files changed, 19 insertions(+), 6 deletions(-) > > > > diff --git a/notmuch-new.c b/notmuch-new.c > > index 15c0b36..92e0489 100644 > > --- a/notmuch-new.c > > +++ b/notmuch-new.c > > @@ -785,8 +785,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; > > @@ -794,12 +796,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_STATUS_SUCCESS; > > notmuch_directory_t *directory; > > notmuch_filenames_t *files, *subdirs; > > char *absolute; > > @@ -812,8 +815,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) > > + goto DONE; > > } > > > > for (subdirs = notmuch_directory_get_child_directories (directory); > > @@ -822,11 +827,15 @@ _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) > > + goto DONE; > > } > > > > + DONE: > > notmuch_directory_destroy (directory); > > + return NOTMUCH_STATUS_SUCCESS; > > Doesn't this need to be return status or something? Arrg. Yes, of course. I wish I knew a good way to test this stuff.