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 SMmKLPMXTmC7DAAA0tVLHw (envelope-from ) for ; Sun, 14 Mar 2021 14:04:35 +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 aNJvKPMXTmDXQQAAB5/wlQ (envelope-from ) for ; Sun, 14 Mar 2021 14:04:35 +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 aspmx1.migadu.com (Postfix) with ESMTPS id 62BAF12BCA for ; Sun, 14 Mar 2021 15:04:35 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id ADB1D28CC6; Sun, 14 Mar 2021 10:03:05 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id B255027C68 for ; Sun, 14 Mar 2021 10:02:39 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id A91B75FA96; Sun, 14 Mar 2021 10:02:39 -0400 (EDT) Received: (nullmailer pid 183657 invoked by uid 1000); Sun, 14 Mar 2021 14:02:19 -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: Sun, 14 Mar 2021 11:02:07 -0300 Message-Id: <20210314140217.183425-13-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: Q77XM4WKE2BUDJRFRVBLH6QULIQ6YNQU X-Message-ID-Hash: Q77XM4WKE2BUDJRFRVBLH6QULIQ6YNQU 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=1615730675; 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=StzmUj1UbgeN37iko2h1f2M4F0LqWB2nINL43pFOoK8=; b=o36+CFme6a6JDLpKWXQaB6CMM9muSY8AaLSHrA+QCy2S14MAxaMrO7pJvaLCL7wArJADfE JaF3ICP4igt+8s9yk6/X93mpOgNiSEOeVndt2o7xMQOViUUyTcR/nOSQfS6uHtswyqRmE2 n+WsC23hdMpoIIB7n4cVSJFsZDTDnLyAdlYEV3dVKIZqXw7osHP6j0J5PtoIoz5vZ8NF+C JWXIdNYFAnAPrO0WjTHcSjWVzGkR0nOlet1docxCa3ZqRozNYC6aO9FL8x6w3VXycrMC74 BrBa/xGm3+H0v0sfCqbsJ9Ee75YnAcycfyo9D71n4qu3/xmlToKq8ckCr94tKg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615730675; a=rsa-sha256; cv=none; b=sVBsiPYCvl/SoypRIdqRhXrepRC6ALc0q3zRg6ovWHcYhCJelbVh4moFQYGO8zFRZnF1P2 cGrKuX3/A+2WsF38TGes4MR4cMNlGjQIxwtMNbDhy438dngFDTPt6zr7LJRWUCTV+vU15J +7nH2iYxGnNzP8J15d3xzPx1WXM0mbf3QGsX7yU1cxsPO198EYJIBEOt72HxWLsDY0OGLc IheuK5FmVu+nqugQgctSOAcVBeAnB+DuoH1pt/krtYIulBS4wxD3WbZff4xmfeMmM9kI9r llY0SQxn1dKRbxrkLb7YJlFCDRn+ib95h6EJ1l0OUVFyIdQryTrz19TeMFTt7g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.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.09 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.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: 62BAF12BCA X-Spam-Score: -1.09 X-Migadu-Scanner: scn0.migadu.com X-TUID: M9LzYmk7GYaW 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 7673e875..54e71fec 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -442,8 +442,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; } @@ -550,12 +549,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