[PATCH v4] lib: Simplify close and codify aborting atomic section

W. Trevor King wking at tremily.us
Thu Oct 2 12:41:34 PDT 2014


On Thu, Oct 02, 2014 at 03:19:08PM -0400, Austin Clements wrote:
> This patch simplifies notmuch_database_close to explicitly abort any
> outstanding transaction and then just call Database::close.  This
> works for both read-only and read/write databases, takes care of
> committing changes, unifies the exception handling path, and codifies
> aborting outstanding transactions.

I don't expect atomic blocks are particularly useful for read-only
connections.  If they aren't, I'd quibble with the “This works for
both read-only…” wording above.  If they are, I'd drop the read/write
check below:

> +	    /* If there's an outstanding transaction, it's unclear if
> +	     * closing the Xapian database commits everything up to
> +	     * that transaction, or may discard committed (but
> +	     * unflushed) transactions.  To be certain, explicitly
> +	     * cancel any outstanding transaction before closing. */
> +	    if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE &&
> +		notmuch->atomic_nesting)
> +		(static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))
> +		    ->cancel_transaction ();

Thats a very minor quibble though, and I'd be glad to see this patch
land as is.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20141002/6a1b6789/attachment.pgp>


More information about the notmuch mailing list