]> git.notmuchmail.org Git - notmuch/commitdiff
lib/generate_thread_id: move static buffer to notmuch_database_t
authorDavid Bremner <david@tethera.net>
Tue, 11 May 2021 11:08:32 +0000 (08:08 -0300)
committerDavid Bremner <david@tethera.net>
Fri, 14 May 2021 09:38:19 +0000 (06:38 -0300)
Work towards the goal of concurrent access to different Xapian
databases from the same process.

lib/add-message.cc
lib/database-private.h

index 0c34d31822bb48a654631d3d41015c905e1fe07a..d4a00b175392710579f7d437d4782cb340ac8a4b 100644 (file)
@@ -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 *
index 0d12ec1efde57b4862f1001facdbfafe3dec54cd..1a73dacc365f563134d123fe09d91668b45a6d1f 100644 (file)
@@ -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