From: Howard Chu Date: Fri, 23 Aug 2013 04:43:29 +0000 (-0700) Subject: ITS#7670 Tweak cursor_del0 X-Git-Tag: OPENLDAP_REL_ENG_2_4_37~39^2~15 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e15a90c7624797afaec703475b6f6be93ca62918;p=openldap ITS#7670 Tweak cursor_del0 Always leave cursor pointing at "next" node, if any. Find next sibling if we're already at end of current page. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index c6a7359a04..43f91c9000 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -7192,6 +7192,7 @@ mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf) int rc; MDB_page *mp; indx_t ki; + unsigned int nkeys; mp = mc->mc_pg[mc->mc_top]; ki = mc->mc_ki[mc->mc_top]; @@ -7211,18 +7212,18 @@ mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf) rc = mdb_rebalance(mc); if (rc != MDB_SUCCESS) mc->mc_txn->mt_flags |= MDB_TXN_ERROR; - /* if mc points past last node in page, invalidate */ - else if (mc->mc_ki[mc->mc_top] >= NUMKEYS(mc->mc_pg[mc->mc_top])) - mc->mc_flags &= ~(C_INITIALIZED|C_EOF); - - { - /* Adjust other cursors pointing to mp */ + else { MDB_cursor *m2; - unsigned int nkeys; MDB_dbi dbi = mc->mc_dbi; mp = mc->mc_pg[mc->mc_top]; nkeys = NUMKEYS(mp); + + /* if mc points past last node in page, find next sibling */ + if (mc->mc_ki[mc->mc_top] >= nkeys) + mdb_cursor_sibling(mc, 1); + + /* Adjust other cursors pointing to mp */ for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { if (m2 == mc) continue; @@ -7232,7 +7233,7 @@ mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf) if (m2->mc_ki[mc->mc_top] > ki) m2->mc_ki[mc->mc_top]--; if (m2->mc_ki[mc->mc_top] >= nkeys) - m2->mc_flags &= ~(C_INITIALIZED|C_EOF); + mdb_cursor_sibling(m2, 1); } } }