From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OBXgLFANRWC6ZgAA0tVLHw (envelope-from ) for ; Sun, 07 Mar 2021 17:28:48 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 4MmCKFANRWCfEgAAbx9fmQ (envelope-from ) for ; Sun, 07 Mar 2021 17:28:48 +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 4A4022468E for ; Sun, 7 Mar 2021 18:28:48 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id DBB5828C51; Sun, 7 Mar 2021 12:28:10 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id B800227C71 for ; Sun, 7 Mar 2021 12:27:50 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 9228C5FA96; Sun, 7 Mar 2021 12:27:50 -0500 (EST) Received: (nullmailer pid 1091634 invoked by uid 1000); Sun, 07 Mar 2021 17:27:38 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 02/22] lib: publish API for notmuch_database_reopen Date: Sun, 7 Mar 2021 13:27:14 -0400 Message-Id: <20210307172734.1091264-3-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210307172734.1091264-1-david@tethera.net> References: <20210307172734.1091264-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 23RHPFCLCJRBVKDIPJO7OFVAMDJNJWN3 X-Message-ID-Hash: 23RHPFCLCJRBVKDIPJO7OFVAMDJNJWN3 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=1615138128; 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=rnwO6nWJidv+E2B9XvAmoxTfcFpmQX5YLuIe72UVysA=; b=AH0LbD85FWgDkI+UimVQX6y3ij/59fG/IGga9WMCmxgaPjzgyuFV/eEwEKxetMeF/Jzwo+ sYeHsf+e20+4TeQH8riSBPI4CiA3IG3Hz9VYge2WoCPQXcv5fJMJJDRzuJ0yOKiIMkmStL TnR9sa1k3vamUFPuHwSfIGc+6a27oyZrCkoKoHzONYulxB0qXw2JiFpWwmU6LbYekJBgW6 hTbpjOvquGJEeTSyMEyNVB7DcJhnz7ED1vRy+lVuoIHdL2Z3BqkHxs+AGdJ4dzmpyHqwLC hsSVNdDjwPZXSPkTMefJEN/vUZZIYZF3y+j9IVpGvPgM7q+NlscN31G9DrSkow== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615138128; a=rsa-sha256; cv=none; b=CsDm6DJqwnQKOdkyneaAWUKaRNXy3Uu23+uzP6zLkm5gD0e8TX9WRW+TkYnTfZiKpyn9lR DdsEZJ65Al8pMCw6FpAMCsrMhig0szv38WxdWfKNbR8vM7pKhKWcE45PyuuM68Lrvgn3Bk zubQbXotQUGncJPOABbc/erml3ibi8vt9bq6esjddgw5kuSkIOShGsrHORfnP9CPypHZX+ 4FE+QR+x1zqsZlwmGGF+MT5c7OIOnW7ZywIhFWG8nyiiGRvJ+kfibcwV/7xtd+yDkQBWVQ Ukz2XwWyiY3iXZ3rF4YPu8C0z2hmSbxiqDkjArSUZ9E+NlhZG2ucb6gl47p0TA== 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: -0.96 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: 4A4022468E X-Spam-Score: -0.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: g/XbiMplURSW 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 b4e536b9..799c008f 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -517,7 +517,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 e47badbc..1174c43c 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 70f4f517..05edac31 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