From 3d6b924c2560f39973de82d2599ce9d6542b9cb2 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 21 Jan 2012 08:20:43 -0800 Subject: [PATCH] txn_commit must abort txn before returning errors Fix for failure when committing a txn that is a child of some parent txn. --- libraries/libmdb/mdb.c | 4 +++- libraries/libmdb/mdb.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 9480a43..cd0e810 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -1737,8 +1737,10 @@ mdb_txn_commit(MDB_txn *txn) } x = dst[0].mid; for (; y<=src[0].mid; y++) { - if (++x >= MDB_IDL_UM_MAX) + if (++x >= MDB_IDL_UM_MAX) { + mdb_txn_abort(txn); return ENOMEM; + } dst[x] = src[y]; } dst[0].mid = x; diff --git a/libraries/libmdb/mdb.h b/libraries/libmdb/mdb.h index c40a5e9..5682c8f 100644 --- a/libraries/libmdb/mdb.h +++ b/libraries/libmdb/mdb.h @@ -530,6 +530,7 @@ int mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn ** *
  • EINVAL - an invalid parameter was specified. *
  • ENOSPC - no more disk space. *
  • EIO - a low-level I/O error occurred while writing. + *
  • ENOMEM - the transaction is nested and could not be merged into its parent. * */ int mdb_txn_commit(MDB_txn *txn);