[PATCH] Actually close the xapian database in notmuch_database_close

Austin Clements amdragon at MIT.EDU
Wed Feb 29 07:48:33 PST 2012


Quoth Justus Winter on Feb 29 at 10:19 am:
> 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.

Interesting.  Is this a bug in Xapian?  According to the docs,
~Database is supposed to close the database (if there are no other
copies, which there shouldn't be), so this should be redundant with
the delete notmuch->xapian_db a few lines down, but your experience
obviously suggests that it isn't and I can't find the code path in
Xapian that would close it in the destructor.

Olly?

> Signed-off-by: Justus Winter <4winter at informatik.uni-hamburg.de>
> ---
>  lib/database.cc |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/database.cc b/lib/database.cc
> index 5efa85e..79cf375 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -726,6 +726,10 @@ notmuch_database_close (notmuch_database_t *notmuch)
>  	}
>      }
>  
> +    if (notmuch->xapian_db != NULL) {
> +	notmuch->xapian_db->close();
> +    }
> +
>      delete notmuch->term_gen;
>      delete notmuch->query_parser;
>      delete notmuch->xapian_db;


More information about the notmuch mailing list