From b37b2a651ff2df3824d3f403538627983d5b81d1 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Fri, 30 May 2014 09:06:08 +0200 Subject: [PATCH] Factor out MDB_TXN_ERROR --- libraries/liblmdb/mdb.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 3653f48562..91fc570f08 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6190,9 +6190,7 @@ new_sub: } } - if (rc != MDB_SUCCESS) - mc->mc_txn->mt_flags |= MDB_TXN_ERROR; - else { + if (rc == MDB_SUCCESS) { /* Now store the actual data in the child DB. Note that we're * storing the user data in the keys field, so there are strict * size limits on dupdata. The actual data fields of the child @@ -6215,10 +6213,8 @@ put_sub: /* converted, write the original data first */ if (dkey.mv_size) { rc = mdb_cursor_put(&mc->mc_xcursor->mx_cursor, &dkey, &xdata, xflags); - if (rc) { - mc->mc_txn->mt_flags |= MDB_TXN_ERROR; - return rc == MDB_KEYEXIST ? MDB_CORRUPTED : rc; - } + if (rc) + goto bad_sub; { /* Adjust other cursors pointing to mp */ MDB_cursor *m2; @@ -6268,7 +6264,12 @@ next_sub: } } } + return rc; +bad_sub: + if (rc == MDB_KEYEXIST) /* should not happen, we deleted that item */ + rc = MDB_CORRUPTED; } + mc->mc_txn->mt_flags |= MDB_TXN_ERROR; return rc; } -- 2.39.5