From 91436a25574597dbd1fd2de5bcd5826a234100d6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 31 Aug 2011 13:57:15 +0930 Subject: [PATCH] tdb2: return TDB_ERR_RDONLY if trying to start a transaction on a R/O tdb. This is more accurate than returning TDB_ERR_EINVAL. --- ccan/tdb2/transaction.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ccan/tdb2/transaction.c b/ccan/tdb2/transaction.c index eda65c52..2f588ef3 100644 --- a/ccan/tdb2/transaction.c +++ b/ccan/tdb2/transaction.c @@ -523,13 +523,22 @@ enum TDB_ERROR tdb_transaction_start(struct tdb_context *tdb) tdb->stats.transactions++; /* some sanity checks */ - if (tdb->read_only || (tdb->flags & TDB_INTERNAL)) { + if (tdb->flags & TDB_INTERNAL) { return tdb->last_error = tdb_logerr(tdb, TDB_ERR_EINVAL, + TDB_LOG_USE_ERROR, + "tdb_transaction_start:" + " cannot start a" + " transaction on an" + " internal tdb"); + } + + if (tdb->read_only) { + return tdb->last_error = tdb_logerr(tdb, TDB_ERR_RDONLY, TDB_LOG_USE_ERROR, "tdb_transaction_start:" " cannot start a" " transaction on a " - "read-only or internal db"); + " read-only tdb"); } /* cope with nested tdb_transaction_start() calls */ -- 2.39.2