From: Howard Chu Date: Mon, 12 Sep 2011 05:23:35 +0000 (-0700) Subject: Merge branch 'mdb.master' of ssh://git-master.openldap.org/~git/git/openldap into... X-Git-Tag: OPENLDAP_REL_ENG_2_4_27~148^2~42 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=92a63ff79026fa3f2373cde4bb6793f132b8f287;p=openldap Merge branch 'mdb.master' of ssh://git-master.openldap.org/~git/git/openldap into mdb.master --- 92a63ff79026fa3f2373cde4bb6793f132b8f287 diff --cc libraries/libmdb/mdb.c index 806d493bb1,d0dfc01d94..225ffc4195 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@@ -951,12 -970,15 +965,12 @@@ mdb_alloc_page(MDB_cursor *mc, int num /* See if there's anything in the free DB */ MDB_cursor m2; MDB_node *leaf; - ULONG *kptr, oldest; + txnid_t *kptr, oldest; - m2.mc_txn = txn; - m2.mc_dbi = FREE_DBI; - m2.mc_snum = 0; - m2.mc_flags = 0; + mdb_cursor_init(&m2, txn, FREE_DBI); mdb_search_page(&m2, NULL, 0); leaf = NODEPTR(m2.mc_pg[m2.mc_top], 0); - kptr = (ULONG *)NODEKEY(leaf); + kptr = (txnid_t *)NODEKEY(leaf); { unsigned int i; @@@ -1322,10 -1343,12 +1337,10 @@@ mdb_txn_commit(MDB_txn *txn if (!txn->mt_u.dirty_list[0].mid) goto done; - DPRINTF("committing txn %lu %p on mdbenv %p, root page %lu", - txn->mt_txnid, txn, (void *)env, txn->mt_dbs[MAIN_DBI].md_root); + DPRINTF("committing txn %zu %p on mdbenv %p, root page %zu", + txn->mt_txnid, (void *)txn, (void *)env, txn->mt_dbs[MAIN_DBI].md_root); - mc.mc_txn = txn; - mc.mc_dbi = FREE_DBI; - mc.mc_flags = 0; + mdb_cursor_init(&mc, txn, FREE_DBI); /* should only be one record now */ if (env->me_pghead) { @@@ -2464,13 -2488,11 +2480,13 @@@ cursor_pop_page(MDB_cursor *mc static int cursor_push_page(MDB_cursor *mc, MDB_page *mp) { - DPRINTF("pushing page %lu on db %u cursor %p", mp->mp_pgno, + DPRINTF("pushing page %zu on db %u cursor %p", mp->mp_pgno, mc->mc_dbi, (void *) mc); - if (mc->mc_snum >= CURSOR_STACK) + if (mc->mc_snum >= CURSOR_STACK) { + assert(mc->mc_snum < CURSOR_STACK); return ENOMEM; + } mc->mc_top = mc->mc_snum++; mc->mc_pg[mc->mc_top] = mp; @@@ -2685,13 -2711,14 +2701,13 @@@ mdb_sibling(MDB_cursor *mc, int move_ri if (mc->mc_snum < 2) { return MDB_NOTFOUND; /* root has no siblings */ } - ptop = mc->mc_top-1; + cursor_pop_page(mc); - DPRINTF("parent page is page %lu, index %u", + DPRINTF("parent page is page %zu, index %u", - mc->mc_pg[ptop]->mp_pgno, mc->mc_ki[ptop]); + mc->mc_pg[mc->mc_top]->mp_pgno, mc->mc_ki[mc->mc_top]); - cursor_pop_page(mc); - if (move_right ? (mc->mc_ki[ptop] + 1u >= NUMKEYS(mc->mc_pg[ptop])) - : (mc->mc_ki[ptop] == 0)) { + if (move_right ? (mc->mc_ki[mc->mc_top] + 1u >= NUMKEYS(mc->mc_pg[mc->mc_top])) + : (mc->mc_ki[mc->mc_top] == 0)) { DPRINTF("no more keys left, moving to %s sibling", move_right ? "right" : "left"); if ((rc = mdb_sibling(mc, move_right)) != MDB_SUCCESS)