From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id dXsFFEjhQGD/LgAA0tVLHw (envelope-from ) for ; Thu, 04 Mar 2021 13:31:52 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id cDJdD0jhQGCUAwAAbx9fmQ (envelope-from ) for ; Thu, 04 Mar 2021 13:31:52 +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) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id 562DF25E23 for ; Thu, 4 Mar 2021 14:31:51 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 18EA227564; Thu, 4 Mar 2021 08:31:37 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 162961FBBC for ; Thu, 4 Mar 2021 08:31:32 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 0D9A85FA96; Thu, 4 Mar 2021 08:31:32 -0500 (EST) Received: (nullmailer pid 4053544 invoked by uid 1000); Thu, 04 Mar 2021 13:31:28 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 02/22] lib: publish API for notmuch_database_reopen Date: Thu, 4 Mar 2021 09:31:05 -0400 Message-Id: <20210304133125.4050229-3-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210304133125.4050229-1-david@tethera.net> References: <20210304133125.4050229-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 6LPU4EI333JIXG2Q6LCK6MOPODP7B4LD X-Message-ID-Hash: 6LPU4EI333JIXG2Q6LCK6MOPODP7B4LD 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=1614864711; 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=0RQna1h9ek0HpWmbruui6L3zIlbKlMDIGeAD4Gyxx2g=; b=duNmr2s9e0ESpnsS2F1uu4TgmJ5oh9zb5cnBvzHUx99Pmo4g/rD0LXmfZgSeSk1N4WQrYG zA+dYXiqYG0KLBXCQdape5ul+igGdjheNRo4WI0xV59/nSdby9h83YiSF1zuEC6G1OKdC+ auxEWnX1lJWH3/Q7Mo/MwG8tOOhV+hyE/Zb9+rtlt7uMNqoo31MP37bXL4Jyo5IG/1fzjw yI22qgx4Bam8teO+W6jxQ0rk0kjhF6BjTPv357mrmln5fSTMB9aXhzsCL4fIC1F6q+eiHx bDd4KxqYfrLxxYo0HR+D550HJlqd4tE7QRDyE2Ksxkbjs+9ML3xpxQ8PE/KDTA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614864711; a=rsa-sha256; cv=none; b=JQVJQ9OCOaTXihQeq3kZCP7NC2wWkawE3ibARR1RRYBRPRACxdgHmowSGqTANYXES/Kuvy T+YVzQ1KARxVBIEuvPCf3uRpbwgajz27/3NqmLlDPWgkd/DBkGTfv/KdI/uOfaJNgPwuq/ D6oR9bEiZdendtKViBslOsV0WkMpbYNOxjYHtsfSJptADBCvrXG6uFLEchMjfrCQlKHYN6 5z5cZCpLoao0Eb/yd64A8WYCClgKrayhDzWyDobQN5VP1C8ggg6Yea80/XproyIzuEkFYQ ueElTQ4NaI6bQXjCSJV6RXS4BALmRUTUUZsWW4XB4+P+JU+F3/6eNQE5SKxylA== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.03 Authentication-Results: aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 562DF25E23 X-Spam-Score: -1.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: T++64ne3ohKr Include the (currently unused) mode argument which will specify which mode to re-open the database in. Functionality and docs to be finalized in a followup commit. --- lib/database.cc | 3 ++- lib/message.cc | 3 ++- lib/notmuch-private.h | 3 --- lib/notmuch.h | 7 +++++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index f96ba7c0..89865599 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -516,7 +516,8 @@ notmuch_database_close (notmuch_database_t *notmuch) } notmuch_status_t -_notmuch_database_reopen (notmuch_database_t *notmuch) +notmuch_database_reopen (notmuch_database_t *notmuch, + unused(notmuch_database_mode_t mode)) { if (_notmuch_database_mode (notmuch) != NOTMUCH_DATABASE_MODE_READ_ONLY) return NOTMUCH_STATUS_UNSUPPORTED_OPERATION; diff --git a/lib/message.cc b/lib/message.cc index fca99082..1bea90f0 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -455,7 +455,8 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message, void *field) /* all the way without an exception */ break; } catch (const Xapian::DatabaseModifiedError &error) { - notmuch_status_t status = _notmuch_database_reopen (message->notmuch); + notmuch_status_t status = notmuch_database_reopen (message->notmuch, + NOTMUCH_DATABASE_MODE_READ_ONLY); if (status != NOTMUCH_STATUS_SUCCESS) INTERNAL_ERROR ("unhandled error from notmuch_database_reopen: %s\n", notmuch_status_to_string (status)); diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 750a242c..2808bbb3 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -204,9 +204,6 @@ _notmuch_message_id_compressed (void *ctx, const char *message_id); notmuch_status_t _notmuch_database_ensure_writable (notmuch_database_t *notmuch); -notmuch_status_t -_notmuch_database_reopen (notmuch_database_t *notmuch); - void _notmuch_database_log (notmuch_database_t *notmuch, const char *format, ...); diff --git a/lib/notmuch.h b/lib/notmuch.h index 5a5d99c0..0c13f607 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -879,6 +879,13 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch, notmuch_tags_t * notmuch_database_get_all_tags (notmuch_database_t *db); +/** + * Reopen an open notmuch database. + * + */ +notmuch_status_t +notmuch_database_reopen (notmuch_database_t *db, notmuch_database_mode_t mode); + /** * Create a new query for 'database'. * -- 2.30.1