From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 5027N84XTmAWFgAA0tVLHw (envelope-from ) for ; Sun, 14 Mar 2021 14:03:58 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 2GPwMs4XTmCgQgAAB5/wlQ (envelope-from ) for ; Sun, 14 Mar 2021 14:03:58 +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)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 679421CF90 for ; Sun, 14 Mar 2021 15:03:58 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id EC4E727D73; Sun, 14 Mar 2021 10:02:53 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 0AB0127C3B for ; Sun, 14 Mar 2021 10:02:33 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id EB6085FA96; Sun, 14 Mar 2021 10:02:33 -0400 (EDT) Received: (nullmailer pid 183633 invoked by uid 1000); Sun, 14 Mar 2021 14:02:19 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 02/22] lib: publish API for notmuch_database_reopen Date: Sun, 14 Mar 2021 11:01:57 -0300 Message-Id: <20210314140217.183425-3-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210314140217.183425-1-david@tethera.net> References: <20210314140217.183425-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: GF7BDSFBNHEYPK6MWV3SALRFOKM26Z5W X-Message-ID-Hash: GF7BDSFBNHEYPK6MWV3SALRFOKM26Z5W 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=1615730638; 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=nnNSSAOVaq4+0SjOg+VcK7O1MeNSAu6jPq4sdAdUr14=; b=I11x2RT5h+890wGYQsyJScajnfjpBBoFVQiEB98CYVQfbQl4Pcb6cFW7WdtrpI5cMEPBbg mHB08dr4rw5Fpii6OHXTtqIZiC6zWUfPrix6TY3Jf0LyqMKqYbmY27aTZ9ZewawzGCg+wf 7TrzHrUU4kRoJ4B/DPWkttWKgAsnDt3P0SP9PKDP+gd6FKRO8yIYQWwcTRxH2nR+NL6dxO EcRvgPEEZViYgPCpmgjZ8jXMaRQywyMCK/e2qtoMhu+MFKhlPt58e/Av5v/WqRHwq6c+a/ kPEA0mqEtXzj/vcw0zmHhLYjMvI2+R7cg/i5eP8Xv5oYBWZeayDLoxehYRffOQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615730638; a=rsa-sha256; cv=none; b=jGLhK2TikR0Tq82Q/0+kqdguTxJLJlub6/ITygQTY9SxeFDbv4iu2imHpD448O9ZVq65ZR LTPVDwwOvjXfjpyqDJvh4Dw6oxRBpKg4yvcu3jPvEWKuxJRYlMIudY44aJERxuf7nGEWjj ILUgpPiQe05OwlBSQn6nc2CAE6OQSq7I9c1P9VPWirsaFyq1ws82ivkErz70gPgRq4CurX DDm+jnTXFTZZR/CfWmcaU0gZstYHOMIAp4JOWP+U/mGdLDmKqPIEuGTSzbt7M0tZe3Ecp8 cp4ub/zSMVUfFFISzeXqCPU2HlOfXuOk+3WvZvIVqCkhsxP4FtstduHpufVq4w== 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.00 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: 679421CF90 X-Spam-Score: -1.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: tiZa0efApPgb 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 f27616da..82ac5f20 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -518,7 +518,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 dc4b47dc..73a7805f 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -459,7 +459,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 3c52cfc2..ef814378 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 58c568d5..db86ffc0 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