X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=16c4354f2448bbc39bff3a1c3f630b4775575cd4;hp=5efa85eb162ab47085f4105ebd5b0a0a86f84ddd;hb=75a05526334b721d719d6c8a8098ff64573e6c1e;hpb=e2e95caa51f8c1ea57b4fc7d3926fda1fb1aed10 diff --git a/lib/database.cc b/lib/database.cc index 5efa85eb..16c4354f 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; @@ -1814,6 +1825,9 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch, if (message_ret == NULL) return NOTMUCH_STATUS_NULL_POINTER; + /* return NULL on any failure */ + *message_ret = NULL; + local = talloc_new (notmuch); try {