lib/generate_thread_id: move static buffer to notmuch_database_t

Work towards the goal of concurrent access to different Xapian
databases from the same process.
This commit is contained in:
David Bremner 2021-05-11 08:08:32 -03:00
parent 8410be8e08
commit 929386fad9
2 changed files with 7 additions and 6 deletions

View file

@ -40,17 +40,14 @@ parse_references (void *ctx,
static const char * static const char *
_notmuch_database_generate_thread_id (notmuch_database_t *notmuch) _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++; 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 * static char *

View file

@ -206,6 +206,10 @@ struct _notmuch_database {
enum _notmuch_features features; enum _notmuch_features features;
unsigned int last_doc_id; 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; uint64_t last_thread_id;
/* error reporting; this value persists only until the /* error reporting; this value persists only until the