diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2012-03-02 15:58:39 +0100 |
---|---|---|
committer | David Bremner <bremner@debian.org> | 2012-03-03 11:30:07 -0400 |
commit | cfc5f1059aa16753cba610c41601cacc97260e08 (patch) | |
tree | 072b2c4268b2fd77bcfe3c115bcac244d3bc6953 /lib/database.cc | |
parent | 3ed8c3d9a6915f7598c3d2aae3c1d8ea9a9ce140 (diff) |
Actually close the xapian database in notmuch_database_close
Formerly the xapian database object was deleted and closed in its
destructor once the object was garbage collected. Explicitly call
close() so that the database and the associated lock is released
immediately.
The comment is a courtesy of Austin Clements.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Diffstat (limited to 'lib/database.cc')
-rw-r--r-- | lib/database.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/database.cc b/lib/database.cc index 5efa85eb..8f8df1a1 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -726,6 +726,17 @@ notmuch_database_close (notmuch_database_t *notmuch) } } + /* Many Xapian objects (and thus notmuch objects) hold references to + * the database, so merely deleting the database may not suffice to + * close it. Thus, we explicitly close it here. */ + if (notmuch->xapian_db != NULL) { + try { + notmuch->xapian_db->close(); + } catch (const Xapian::Error &error) { + /* do nothing */ + } + } + delete notmuch->term_gen; delete notmuch->query_parser; delete notmuch->xapian_db; |