aboutsummaryrefslogtreecommitdiff
path: root/lib/database.cc
diff options
context:
space:
mode:
authorIstvan Marko <notmuch@kismala.com>2016-06-26 17:29:43 +0200
committerDavid Bremner <david@tethera.net>2016-06-29 09:03:34 +0200
commit9b60dc3cd9224eddfe9bc5cf74eeaa5f0d599d04 (patch)
treea577334efff26292a4321886f3862c276862f84b /lib/database.cc
parent496dccf44fadf4c8ee190e98d3cba54a8e828f97 (diff)
Use the Xapian::DB_RETRY_LOCK flag when available
Xapian 1.3 has introduced the DB_RETRY_LOCK flag (Xapian bug 275). Detect it in configure and optionally use it. With this flag commands that need the write lock will wait for their turn instead of aborting when it's not immediately available. Amended by db: allow disabling in configure
Diffstat (limited to 'lib/database.cc')
-rw-r--r--lib/database.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/database.cc b/lib/database.cc
index afafe88c..66ee267f 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -49,6 +49,12 @@ typedef struct {
#define STRINGIFY(s) _SUB_STRINGIFY(s)
#define _SUB_STRINGIFY(s) #s
+#if HAVE_XAPIAN_DB_RETRY_LOCK
+#define DB_ACTION (Xapian::DB_CREATE_OR_OPEN | Xapian::DB_RETRY_LOCK)
+#else
+#define DB_ACTION Xapian::DB_CREATE_OR_OPEN
+#endif
+
/* Here's the current schema for our database (for NOTMUCH_DATABASE_VERSION):
*
* We currently have three different types of documents (mail, ghost,
@@ -939,7 +945,7 @@ notmuch_database_open_verbose (const char *path,
if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {
notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path,
- Xapian::DB_CREATE_OR_OPEN);
+ DB_ACTION);
} else {
notmuch->xapian_db = new Xapian::Database (xapian_path);
}