From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id B91B86DE0C97 for ; Mon, 28 Nov 2016 04:22:35 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.006 X-Spam-Level: X-Spam-Status: No, score=-0.006 tagged_above=-999 required=5 tests=[AWL=0.005, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jKbX1F5tZCCM for ; Mon, 28 Nov 2016 04:22:35 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id EB2BC6DE0C6D for ; Mon, 28 Nov 2016 04:22:34 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cBKwm-0001gq-Tz; Mon, 28 Nov 2016 07:22:12 -0500 Received: (nullmailer pid 6486 invoked by uid 1000); Mon, 28 Nov 2016 12:22:32 -0000 From: David Bremner To: Maarten Aertsen , Notmuch Mail Subject: Re: [PATCH 2/2] cli/insert: return EX_TEMPFAIL for some errors In-Reply-To: <20161128121641.4022-2-david@tethera.net> References: <87r3gn8lfm.fsf@maritornes.cs.unb.ca> <20161128121641.4022-1-david@tethera.net> <20161128121641.4022-2-david@tethera.net> Date: Mon, 28 Nov 2016 08:22:32 -0400 Message-ID: <874m2rx08n.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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, 28 Nov 2016 12:22:35 -0000 David Bremner writes: > Attempt to distinguish between errors indicating misconfiguration or > programmer error, which we consider "permanant", in the sense that > automatic retries are unlikely to be useful, and those indicating > transient error conditions. We consider XAPIAN_EXCEPTION transient > because it covers the important special case of locking failure. > --- > notmuch-client.h | 3 +++ > notmuch-insert.c | 9 +++++---- > status.c | 16 ++++++++++++++++ > test/T070-insert.sh | 24 ++++++++++++++---------- > 4 files changed, 38 insertions(+), 14 deletions(-) > > diff --git a/notmuch-client.h b/notmuch-client.h > index 793f32e..d026e60 100644 > --- a/notmuch-client.h > +++ b/notmuch-client.h > @@ -489,6 +489,9 @@ print_status_database (const char *loc, > const notmuch_database_t *database, > notmuch_status_t status); > > +int > +status_to_exit (notmuch_status_t status); > + > #include "command-line-arguments.h" > > extern char *notmuch_requested_db_uuid; > diff --git a/notmuch-insert.c b/notmuch-insert.c > index 862da88..a152f15 100644 > --- a/notmuch-insert.c > +++ b/notmuch-insert.c > @@ -538,9 +538,10 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) > return EXIT_FAILURE; > } > > - if (notmuch_database_open (notmuch_config_get_database_path (config), > - NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) > - return EXIT_FAILURE; > + status = notmuch_database_open (notmuch_config_get_database_path (config), > + NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much); > + if (status) > + return status_to_exit(status); I guess this should return NOTMUCH_STATUS_SUCCESS if --keep is passed. > notmuch_exit_if_unmatched_db_uuid (notmuch); > > @@ -577,5 +578,5 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) > notmuch_run_hook (db_path, "post-insert"); > } > > - return status ? EXIT_FAILURE : EXIT_SUCCESS; > + return status ? status_to_exit(status) : EXIT_SUCCESS; This can be simplified to just "return status_to_exit (status)". And whitespace fixes for both calls to status_to_exit. > +int > +status_to_exit (notmuch_status_t status) > +{ > + switch (status) { > + case NOTMUCH_STATUS_SUCCESS: > + return EXIT_SUCCESS; > + case NOTMUCH_STATUS_OUT_OF_MEMORY: > + case NOTMUCH_STATUS_XAPIAN_EXCEPTION: > + case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: > + case NOTMUCH_STATUS_FILE_ERROR: > + return EX_TEMPFAIL; > + default: > + return EXIT_FAILURE; > + } This classification is pretty arbitrary. The main goal is have locking errors, which are currently NOTMUCH_STATUS_XAPIAN_EXCEPTION treated as TEMPFAIL. d