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 aPcIC14NRWAiUwAA0tVLHw (envelope-from ) for ; Sun, 07 Mar 2021 17:29:02 +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 GE/dBl4NRWDSVgAA1q6Kng (envelope-from ) for ; Sun, 07 Mar 2021 17:29:02 +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 B9709149D8 for ; Sun, 7 Mar 2021 18:29:01 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 346D228C5A; Sun, 7 Mar 2021 12:28:17 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 5F8B427C50 for ; Sun, 7 Mar 2021 12:27:53 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 599255FA96; Sun, 7 Mar 2021 12:27:53 -0500 (EST) Received: (nullmailer pid 1091658 invoked by uid 1000); Sun, 07 Mar 2021 17:27:38 -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, 7 Mar 2021 13:27:24 -0400 Message-Id: <20210307172734.1091264-13-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: RZ3OEC7KNCK22OUQ4UJ7NPU726MDVHAV X-Message-ID-Hash: RZ3OEC7KNCK22OUQ4UJ7NPU726MDVHAV 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=1615138141; 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=ecNRFh+jMdbwYsNJ8LONHoxo8WV/tTmCn4pgHMMBg1Q=; b=txW7fd8UPqrSmFeWbC9pLCx925acYKaTXfH/aVa43aOOt8uC6Qe8tD4LSzvvwNYW0X4qVf uEASC9ws8Oi/Gsv4Q82dIEdBRKxFH/QSljhIcxtsqaMCYkQ77jx025z+0dpCwGYG+fs3IZ BqehsOlEnv5Ut95riBxVmxdKrFCDKc9B6S8kiiEXMdeWKRoIEvugirixx2hKP4RirpkPW5 vMSfucszPOtauOVe5U1eDPa0k1QGf3Lvo6wV/ULXEm8LBUN7Aio3uNvRR26RQNs2OznJFY iiwzBbEaeV/iUE44pfzSHKeMNCbDp+ExQmXNWPw9x4hK9/Qi/+mgpw+7lOqSoQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615138141; a=rsa-sha256; cv=none; b=VLCGLCuiqdA7L4fP/z93AdMT6s3jeYZgsW11CZ7r8e9rW0m30smCiNa11AxHaNbCt+V7Ao 6mBGdDr6WWSlSH/HE2zKvHGU4zPA2C1PqQj5vY74FDJx115RepjudJStnvPDVDvNjip6sx GCT8Ph6JyBQsQPWuFnNStNm2SJOzNGva0aSog84yzxWrgM+xMFp31qEVenzCMC8BlZ5ete U1WA2j420J0ayVpDcjEueqLJfaeTbjW2cZynyVVAfphn38cx0YHqAXafG2t2f5Bc7T7Iu+ OuRNeBE+HsD4fBQ/U2LNLrteDVNf3++CAO8NuZWv3Ry5hhQPQmef3OawxH+8fw== 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.74 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: B9709149D8 X-Spam-Score: -0.74 X-Migadu-Scanner: scn1.migadu.com X-TUID: sSHk4Qv3ZJFA 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 d8e69319..e59cfcdc 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -439,8 +439,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; } @@ -545,12 +544,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