Commit 91436a25 authored by Rusty Russell's avatar Rusty Russell

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.
parent 6b7c3c84
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment