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 ms0.migadu.com with LMTPS id 6Nw3F3z6nGDZnwAAgWs5BA (envelope-from ) for ; Thu, 13 May 2021 12:07:56 +0200 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 cGi/Enz6nGCgdQAAbx9fmQ (envelope-from ) for ; Thu, 13 May 2021 10:07:56 +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) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D814586F0 for ; Thu, 13 May 2021 12:07:55 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 0A9B427E20; Thu, 13 May 2021 06:07:33 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 0ED442717B for ; Thu, 13 May 2021 06:07:20 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 06FFC60018; Thu, 13 May 2021 06:07:19 -0400 (EDT) Received: (nullmailer pid 1460731 invoked by uid 1000); Thu, 13 May 2021 10:07:13 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 2/7] lib/generate_thread_id: move static buffer to notmuch_database_t Date: Thu, 13 May 2021 07:07:05 -0300 Message-Id: <20210513100710.1460566-3-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210513100710.1460566-1-david@tethera.net> References: <20210513100710.1460566-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: KLHWD4JZJXLZAO7URJNUPKYHLOMY7EVS X-Message-ID-Hash: KLHWD4JZJXLZAO7URJNUPKYHLOMY7EVS 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=1620900475; 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=j3wi1TkeY5IbDDM/lJim+bUPpm2zwX7GC2wuFDmyYeA=; b=WKe//1XdFHv9wdSWeSgCYuuSfsDnnon/9DPrZdwHTBDl9sDJtfPs7yw7Lx9ICWkWyhOq6W DNuVDDP42S8RXEarkRORaSdXLuC6W4WOTwt6tGmRP03EfhjGtOUcLps73dKLYKeiJpSZPE BcmYBfceld12mRSi3hfn/mtAfU/vwNJo869j/epoVojOLawR0h+L4lh2mSb5EolcQzPGix iyCbKEzmNWiymbiJY6AIiy1qG60qxR7ZuoCZW1uagVT17wZzrjw7GcGr89TAirYCJULra/ p0yhDgQ2g3Rgz8AHCKrzuUzsJO0wypcz9S/JadvFP0tJb9KomHmDCTLhUV+Www== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620900475; a=rsa-sha256; cv=none; b=sVWJ2306l3htSIs0o/GwH0+vNs1V6ULjhSUbohxkFZFatGEd72r7Ozv6W55atJjmphHL20 DDWtq9XbRvwKxzjoHoyoTKh267yA5KFRVjyWbunqxjWoa6E8uBkcmjEzcdi305HunvURMJ 21yRIfQtfYi63v3fR41uv+NJTimg6Cvv/8EHu3DdGhj/7ztfv04s7+5OdvpT8QWC5xsAZE FuDlabMZQou58qeZFAYOsWzuddIiytNmR0hpT79Tl9DrwXhR/yImA2puMo7sT5N4DezOO2 C1VgXC9eplOojXw/5FcYuOYpJS8csCfhjPSmBSbcK8GnQYwvAvCunZ12Vbd3xg== 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.46 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: D814586F0 X-Spam-Score: 0.46 X-Migadu-Scanner: scn0.migadu.com X-TUID: 1V7bIooTpb09 Work towards the goal of concurrent access to different Xapian databases from the same process. --- lib/add-message.cc | 9 +++------ lib/database-private.h | 4 ++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/add-message.cc b/lib/add-message.cc index 0c34d318..d4a00b17 100644 --- a/lib/add-message.cc +++ b/lib/add-message.cc @@ -40,17 +40,14 @@ parse_references (void *ctx, static const char * _notmuch_database_generate_thread_id (notmuch_database_t *notmuch) { - /* 16 bytes (+ terminator) for hexadecimal representation of - * a 64-bit integer. */ - static char thread_id[17]; notmuch->last_thread_id++; - sprintf (thread_id, "%016" PRIx64, notmuch->last_thread_id); + sprintf (notmuch->thread_id_str, "%016" PRIx64, notmuch->last_thread_id); - notmuch->writable_xapian_db->set_metadata ("last_thread_id", thread_id); + notmuch->writable_xapian_db->set_metadata ("last_thread_id", notmuch->thread_id_str); - return thread_id; + return notmuch->thread_id_str; } static char * diff --git a/lib/database-private.h b/lib/database-private.h index 0d12ec1e..1a73dacc 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -206,6 +206,10 @@ struct _notmuch_database { enum _notmuch_features features; unsigned int last_doc_id; + + /* 16 bytes (+ terminator) for hexadecimal representation of + * a 64-bit integer. */ + char thread_id_str[17]; uint64_t last_thread_id; /* error reporting; this value persists only until the -- 2.30.2