]> git.notmuchmail.org Git - notmuch/commitdiff
Actually close the xapian database in notmuch_database_close
authorJustus Winter <4winter@informatik.uni-hamburg.de>
Fri, 2 Mar 2012 14:58:39 +0000 (15:58 +0100)
committerDavid Bremner <bremner@debian.org>
Sat, 3 Mar 2012 15:30:07 +0000 (11:30 -0400)
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>
lib/database.cc

index 5efa85eb162ab47085f4105ebd5b0a0a86f84ddd..8f8df1a1434ed604ca2fe1a7bdf5f87b7084a28d 100644 (file)
@@ -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;