summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:15:13 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:15:13 +0930
commit37c704be0af3b5915e6630264dc4379309d83160 (patch)
tree6afc656aeb0adc3031278fbd33a9e853a4780915 /lib
parent2cf3f7c07499f565101e1bcb835c73fc297ea72e (diff)
downloadsamba-37c704be0af3b5915e6630264dc4379309d83160.tar.gz
samba-37c704be0af3b5915e6630264dc4379309d83160.tar.bz2
samba-37c704be0af3b5915e6630264dc4379309d83160.zip
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. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 91436a25574597dbd1fd2de5bcd5826a234100d6)
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb2/transaction.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/tdb2/transaction.c b/lib/tdb2/transaction.c
index eda65c5208..2f588ef37a 100644
--- a/lib/tdb2/transaction.c
+++ b/lib/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 */