From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iNHMM4kHVGAuEQAA0tVLHw (envelope-from ) for ; Fri, 19 Mar 2021 02:08:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id IMOIL4kHVGBdGQAAB5/wlQ (envelope-from ) for ; Fri, 19 Mar 2021 02:08:09 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 08AB011F06 for ; Fri, 19 Mar 2021 03:08:09 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 9C8662757D; Thu, 18 Mar 2021 22:07:55 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 9641220613 for ; Thu, 18 Mar 2021 22:07:50 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id AAA155FAA5; Thu, 18 Mar 2021 22:07:49 -0400 (EDT) Received: (nullmailer pid 1491996 invoked by uid 1000); Fri, 19 Mar 2021 02:07:47 -0000 From: David Bremner To: Matthew Lear , notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 2/2] CLI/new: drop the write lock to run the pre-new hook. Date: Thu, 18 Mar 2021 23:07:43 -0300 Message-Id: <20210319020743.1491945-2-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210319020743.1491945-1-david@tethera.net> References: <9C1993DF-84BD-4199-A9C8-BADA98498812@bubblegen.co.uk> <20210319020743.1491945-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 4SSS3XDN7WNFWER6CTJTSFDBHE4QMVE5 X-Message-ID-Hash: 4SSS3XDN7WNFWER6CTJTSFDBHE4QMVE5 X-MailFrom: bremner@tethera.net 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-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1616119689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fTe/Fx4j2+aUDlXi2rU9ahDym6tOzo5bQJRpj7iwR8s=; b=dZlnJQD3bJj9iKLLvSXpj5bkoUDlxOXDkVR9ZIk4SKtmfDZRXbTFT7HxQaa8qMiPKRwGPl 1xGXgU9vQNs6axx/6Hqv8AYNw2Puz+lONY1EeFXBLR/2Bll7XqV/1+V8YE49t8iIBUZx78 5R/gw2gzULowHzRjyUy1sx/Q0rlez9eLXfvamLQ5dC5g/d4V+vbUzkyujNWklHMbM3llQe AGSxDeXcNNZLFCJyh4/1kKmg25zo9mGE8owA4edNgM7YuIteNovRouDxZqvx6liaujBwMG HjmbgjRByKfIcJbe8CoxEfJEzce5k2enl7S3wBvKJ/1NowahG+/3P2TkUKwQWQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616119689; a=rsa-sha256; cv=none; b=W39w25rnf8X7iA21D4y3Gv0duFb29qk4MnLIQO0urlsteDOBnEdsOD+c6cZlKl0pkG6H1B FE9Vtb8VmI58BlfDIL2EwBD+9E0LqwHgUhcCCw4neAfVr0cTZtCf12/9BKoaCnpcHIU69W bV7JJT9WLe0J5eu1qoh/g7+hr0Aek4EcXoV+Dvr1VlCwiyCofFuf+sm+++A1cxJ32y1DxS faQXFY7xbkRJz7khRIvTYyki0QC/3paQhZ49ixkPwHqytN3KkeiwyQx420FLAXP5ho1N3+ Iz2udpUPvEkWAXovbzt07nreyN29vV4IF/LX+Y/OnYTJupNm/q7J2P0lujNphA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.06 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 08AB011F06 X-Spam-Score: -1.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: 75S/qK5upqpd This fixes a bug reported in [1]. In principle it could be possible avoid one of these reopens, but it complicates the logic in main with respect to creating new databases. [1]: id:9C1993DF-84BD-4199-A9C8-BADA98498812@bubblegen.co.uk --- notmuch-new.c | 10 ++++++++++ test/T400-hooks.sh | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/notmuch-new.c b/notmuch-new.c index 223d68bb..8214fb23 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -1170,9 +1170,19 @@ notmuch_new_command (unused(notmuch_config_t *config), notmuch_database_t *notmu } if (hooks) { + /* Drop write lock to run hook */ + status = notmuch_database_reopen (notmuch, NOTMUCH_DATABASE_MODE_READ_ONLY); + if (print_status_database ("notmuch new", notmuch, status)) + return EXIT_FAILURE; + ret = notmuch_run_hook (notmuch, "pre-new"); if (ret) return EXIT_FAILURE; + + /* acquire write lock again */ + status = notmuch_database_reopen (notmuch, NOTMUCH_DATABASE_MODE_READ_WRITE); + if (print_status_database ("notmuch new", notmuch, status)) + return EXIT_FAILURE; } notmuch_exit_if_unmatched_db_uuid (notmuch); diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh index a2b67d59..de8e4ba4 100755 --- a/test/T400-hooks.sh +++ b/test/T400-hooks.sh @@ -159,7 +159,6 @@ EOF test_expect_equal_file write.expected write.output test_begin_subtest "pre-new with write access [${config}]" - test_subtest_known_broken rm -rf ${HOOK_DIR} create_write_hook "pre-new" write.expected write.output $HOOK_DIR NOTMUCH_NEW -- 2.30.2