From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YKjhBgmkAF/WNwAA0tVLHw (envelope-from ) for ; Sat, 04 Jul 2020 15:45:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id gMLYAgmkAF+QDQAA1q6Kng (envelope-from ) for ; Sat, 04 Jul 2020 15:45:13 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5F26D940900 for ; Sat, 4 Jul 2020 15:45:11 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3617E1FAE6; Sat, 4 Jul 2020 11:45:05 -0400 (EDT) Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by mail.notmuchmail.org (Postfix) with ESMTPS id 2E9191FA20 for ; Sat, 4 Jul 2020 11:45:03 -0400 (EDT) Received: by mail-ej1-x641.google.com with SMTP id lx13so18864461ejb.4 for ; Sat, 04 Jul 2020 08:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:in-reply-to:references:date:message-id :mime-version; bh=lwCxLq3nD1wvGq0XagPf1gs+kAUyfk66JBoPKEBRU20=; b=svn81Mz5p4rL3uziwKMuOeAW1dia21CAK07kKyY6eeupIkR0ftgFB8AW+8CHoaXXRf IQdD37aToinxddSg5HEpTgAgrhI+NJZ+aCNBg+LB/QJYHwH05IlyV3l7F18Sxkh1fLe9 rXvqC1Rhusiq+QAfsBlc2Cj2gpAyi3EMQcKKA5Gmpgeg0PuQ57eIMM5CZ1kJow27mxV7 FBT34+Q+DC2wQiDL6ZApMb6l06oMuqitph8xsM1eK2N1QUdWta9g9GPiQ/d+jpZSCAEg 2FI9TtUr4+0qO1RHSS6rG/L4EpULuT2wLUHA50NHoIH2cIlYKThwuHjQXUyHkRbfl6ze ZNmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:in-reply-to:references :date:message-id:mime-version; bh=lwCxLq3nD1wvGq0XagPf1gs+kAUyfk66JBoPKEBRU20=; b=nivB261Wa/ATgARiBSaDPrOjB029md2OHAErmY3ILtR9CP/21gQx8oHgJT3+yyKNxB 5lZp3AVdfaSVPD0lIHLxugZbsgv4jz5E7jAlJGMo8B7bz4lO1GAcXfc7vD/bAFXgRppt HOpn9t3Z65iedhEQsPAi8osgvPwTEIPaLMWlXounJeDqplSrkO4Yde3OqD7RFsw6nGHx mZjlmgF3IHKqGScfoj0+voMOa8OVvZPn88Q99ks0RHf1A+Huyo/KOz7NMvWP9meO+4pL k1dpIVGJrv/XqPePCgP4icp7gQiVgi+PZsEAGYs1J4wgx903RRN3t2WdWeUhQkUu4duC fRqw== X-Gm-Message-State: AOAM533szXdOxzARjboO2AjEvdfN4RnQKc4f7V926lKGRKL7uvCt1gR6 8cwzRwVqAR8v3xJgKOSPJ6vGAvqS X-Google-Smtp-Source: ABdhPJx+C8c+tVyyTmGAw++xXLy1Icl5OqVveBNEXDOwF1jr/YiqgLxA2P2CgROhGBLL4os5fjFJFw== X-Received: by 2002:a17:906:cd2:: with SMTP id l18mr38334087ejh.18.1593877497538; Sat, 04 Jul 2020 08:44:57 -0700 (PDT) Received: from powell.devork.be (2a02-8388-8480-1180-4c18-fc69-8d8c-22b5.cable.dynamic.v6.surfer.at. [2a02:8388:8480:1180:4c18:fc69:8d8c:22b5]) by smtp.gmail.com with ESMTPSA id g6sm12098706ejz.19.2020.07.04.08.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 08:44:57 -0700 (PDT) Sender: Floris Bruynooghe Received: (nullmailer pid 238356 invoked by uid 1000); Sat, 04 Jul 2020 15:44:56 -0000 From: Floris Bruynooghe To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 2/4] lib: catch error from closed db in n_m_get_message_id In-Reply-To: <20200630011411.612552-3-david@tethera.net> References: <20200630011411.612552-1-david@tethera.net> <20200630011411.612552-3-david@tethera.net> Date: Sat, 04 Jul 2020 17:44:56 +0200 Message-ID: <87h7unxp1j.fsf@powell.devork.be> MIME-Version: 1.0 Message-ID-Hash: X5LZGYSKI5XI2CCVSSHDZUK2GAZNH5LK X-Message-ID-Hash: X5LZGYSKI5XI2CCVSSHDZUK2GAZNH5LK X-MailFrom: floris.bruynooghe@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=gmail.com header.s=20161025 header.b=svn81Mz5; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 1.53 X-TUID: X7g9tT8d6GVg Nice. On Mon 29 Jun 2020 at 22:14 -0300, David Bremner wrote: > diff --git a/lib/notmuch.h b/lib/notmuch.h > index ceb5a018..0dc89547 100644 > --- a/lib/notmuch.h > +++ b/lib/notmuch.h > @@ -1363,9 +1363,8 @@ notmuch_message_get_database (const notmuch_message_t *message); > * message is valid, (which is until the query from which it derived > * is destroyed). > * > - * This function will not return NULL since Notmuch ensures that every > - * message has a unique message ID, (Notmuch will generate an ID for a > - * message if the original file does not contain one). > + * This function will return NULL if triggers an unhandled Xapian > + * exception. > */ > const char * > notmuch_message_get_message_id (notmuch_message_t *message); How much of a departure from the existing API is this? Will this be possible with all functions? I had a quick look and tried some other functions that don't return notmuch_status_t: notmuch_database_get_version currently returns and unsigned int and segfaults on use with a closed db. notmuch_needs_upgrade returns notmuch_bool_t and seems to return a valid bool with a closed db. I'm not sure if this is always the right answer though. I wonder if a backwards-compatible errno-style API could work, notmuch_last_status(notmuch_database_t* database) or so. This kind of thing is probably easy to adopt in bindings but harder for direct users of the API. It's also an extra API call for everything that doesn't return notmuch_status_t. But I'll leave the judgement to you, I'm not as experienced with the API.