From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 6ObQGVHhQGBlMQAA0tVLHw (envelope-from ) for ; Thu, 04 Mar 2021 13:32:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id aKWqFVHhQGCvLAAA1q6Kng (envelope-from ) for ; Thu, 04 Mar 2021 13:32:01 +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 1F42222BC4 for ; Thu, 4 Mar 2021 14:32:01 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 931762757B; Thu, 4 Mar 2021 08:31:42 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id D92DC2705F for ; Thu, 4 Mar 2021 08:31:33 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id D14665FA96; Thu, 4 Mar 2021 08:31:33 -0500 (EST) Received: (nullmailer pid 4053568 invoked by uid 1000); Thu, 04 Mar 2021 13:31:28 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 12/22] lib/open: use _finish_open in n_d_create_with_config Date: Thu, 4 Mar 2021 09:31:15 -0400 Message-Id: <20210304133125.4050229-13-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: EGGRC4QACI5EFAAL3HTQMTEW2OLFRXY6 X-Message-ID-Hash: EGGRC4QACI5EFAAL3HTQMTEW2OLFRXY6 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=1614864721; 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=uuz+PMrwTTwXJ/mkuCMhLIMtaLdrPTwio1HJTMuVX9g=; b=hsOcmW2rfcD8jYvLjVu5fuK3NvDlqAV5KBJRvf2hVQ+wPRFdctjzdyCmXCBR5t7OODWyOV WLwuhINsknuItOMGcRLhU89aNHWbasb9+Tz7UNuZdEN0Jvoi0QJSDb0Fy9EjFAtPTXQSYu 6ynR9C9YOnnOblT+fk/XHXbVlveVaVCulYfnTtZXEsTa6d6Bmgg6ZOncaneAgzwz9p7hqW IblvFL2szYjDm4VChQCgxuZJJAWDn1jb3zQHwTaIUkcta6e3EIpnxCBfbAo2gfWP86ol4g q0A+AgT/XA/j6zO93Qn0j7FNqzYLV99AH3TLftOqPTnrisjm447CMabF7iqGtA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614864721; a=rsa-sha256; cv=none; b=RJmQuIv8RJzRmChb8giB/VFGiIYi4sdXJig3eduSI5Zk1/Ka93eRMAk1w8Goi3J7OzMsl2 RiWy45iNO/cPbyDBzzlo2Fsp7Irhas3Dfj0KUcqzIDd+sBNkRteTdqowoM0Y+rqhyAX14s B7j6Ki0Ke8pf29WK5lNlYXEtoWuCxfdp2cI1OWXX7sLOZordATD6C+78/ZtRqSqvS8DiMu 8NN7y0i+hzx5WVNQG958PoV3+c1oOw8iE/F5a6Ic40nENtZwjr91sCV9uYxDxY4SfWrp8x WuXFbY0CfjAX2cERzJRSHQ56Ppm52BiwZu7SuqDRBJjBdbpTy3reQ75hQ9BUkw== 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: 1F42222BC4 X-Spam-Score: -0.96 X-Migadu-Scanner: scn1.migadu.com X-TUID: 4iT1qIssrDFF This avoids reading the configuration file twice. --- lib/open.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index d052f95d..ebf70c15 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -429,8 +429,7 @@ notmuch_database_open_with_config (const char *database_path, if (status) goto DONE; - if (! (notmuch->xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) { - message = strdup ("Out of memory\n"); + if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) { status = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; } @@ -531,12 +530,16 @@ notmuch_database_create_with_config (const char *database_path, goto DONE; } - /* XXX this reads the config file twice, which is a bit wasteful */ - status = notmuch_database_open_with_config (database_path, - NOTMUCH_DATABASE_MODE_READ_WRITE, - config_path, - profile, - ¬much, &message); + if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) { + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } + + status = _finish_open (notmuch, + profile, + NOTMUCH_DATABASE_MODE_READ_WRITE, + key_file, + &message); if (status) goto DONE; -- 2.30.1