mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:14:14 +08:00
lmdb: ITS#7377 Catch mdb_put() to blocked/read-only txns.
...early enough that txn state is left unchanged. Change-Id: Ia475660f339f7b741eaaa126978f8419a19b67a0
This commit is contained in:
parent
d6b3c6f710
commit
061fe51e8c
7
mdb.c
7
mdb.c
@ -7962,10 +7962,10 @@ int
|
||||
mdb_del(MDB_txn *txn, MDB_dbi dbi,
|
||||
MDB_val *key, MDB_val *data)
|
||||
{
|
||||
if (!key || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID))
|
||||
if (unlikely(!key || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID)))
|
||||
return EINVAL;
|
||||
|
||||
if (txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_BLOCKED))
|
||||
if (unlikely(txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_BLOCKED)))
|
||||
return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN;
|
||||
|
||||
if (!F_ISSET(txn->mt_dbs[dbi].md_flags, MDB_DUPSORT)) {
|
||||
@ -8435,6 +8435,9 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi,
|
||||
if (flags & ~(MDB_NOOVERWRITE|MDB_NODUPDATA|MDB_RESERVE|MDB_APPEND|MDB_APPENDDUP))
|
||||
return EINVAL;
|
||||
|
||||
if (txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_BLOCKED))
|
||||
return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN;
|
||||
|
||||
mdb_cursor_init(&mc, txn, dbi, &mx);
|
||||
return mdb_cursor_put(&mc, key, data, flags);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user