]> git.sur5r.net Git - openldap/commitdiff
Restructured to avoid direct use of sl_malloc functions. Minimizes impact
authorHoward Chu <hyc@openldap.org>
Sun, 25 May 2003 00:53:08 +0000 (00:53 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 25 May 2003 00:53:08 +0000 (00:53 +0000)
of #ifdef USE_SL_MALLOC...

16 files changed:
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/bind.c
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/compare.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/dn2entry.c
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/index.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/passwd.c
servers/slapd/back-bdb/proto-bdb.h
servers/slapd/back-bdb/referral.c
servers/slapd/back-bdb/search.c
servers/slapd/back-bdb/tools.c

index af22dfd18559d07a076d02841da95ecd4314441b..0ccf2db32f974904b076ce3f5a9fa8b40c68bac7 100644 (file)
@@ -138,8 +138,8 @@ retry:      /* transaction retry */
        }
 
        /* get entry or parent */
-       rs->sr_err = bdb_dn2entry( op->o_bd, ltid, &op->ora_e->e_nname, &ei,
-               1, locker, &lock, op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2entry( op, ltid, &op->ora_e->e_nname, &ei,
+               1, locker, &lock );
        switch( rs->sr_err ) {
        case 0:
                rs->sr_err = LDAP_ALREADY_EXISTS;
@@ -384,8 +384,7 @@ retry:      /* transaction retry */
        }
 
        /* dn2id index */
-       rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, ei, op->oq_add.rs_e,
-               op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2id_add( op, lt2, ei, op->oq_add.rs_e );
        if ( rs->sr_err != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG ( OPERATION, ERR, 
index 0d8717c8134ce4e1186ece827630ebd4a5a3a2fc..c0ce0312c990321a60b043bbb40aba265a6149ac 100644 (file)
@@ -59,8 +59,8 @@ bdb_bind( Operation *op, SlapReply *rs )
 
 dn2entry_retry:
        /* get entry with reader lock */
-       rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &op->o_req_ndn, &ei, 1,
-               locker, &lock, op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1,
+               locker, &lock );
 
        switch(rs->sr_err) {
        case DB_NOTFOUND:
index bf965d4cd16524987e6e79ff61280eba3b9651b9..d1e99534637253b2f4ebf7273a792f296a7c6b52 100644 (file)
@@ -320,15 +320,14 @@ bdb_entryinfo_add_internal(
  */
 int
 bdb_cache_find_ndn(
-       Backend         *be,
+       Operation       *op,
        DB_TXN          *txn,
        struct berval   *ndn,
        EntryInfo       **res,
-       u_int32_t       locker,
-       void            *ctx
+       u_int32_t       locker
 )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        EntryInfo       ei, *eip, *ei2;
        int rc = 0;
        char *ptr;
@@ -337,13 +336,13 @@ bdb_cache_find_ndn(
        if ( *res ) {
                /* we're doing a onelevel search for an RDN */
                ei.bei_nrdn.bv_val = ndn->bv_val;
-               ei.bei_nrdn.bv_len = dn_rdnlen( be, ndn );
+               ei.bei_nrdn.bv_len = dn_rdnlen( op->o_bd, ndn );
                eip = *res;
        } else {
                /* we're searching a full DN from the root */
-               ptr = ndn->bv_val + ndn->bv_len - be->be_nsuffix[0].bv_len;
+               ptr = ndn->bv_val + ndn->bv_len - op->o_bd->be_nsuffix[0].bv_len;
                ei.bei_nrdn.bv_val = ptr;
-               ei.bei_nrdn.bv_len = be->be_nsuffix[0].bv_len;
+               ei.bei_nrdn.bv_len = op->o_bd->be_nsuffix[0].bv_len;
                eip = &bdb->bi_cache.c_dntree;
        }
        
@@ -356,7 +355,7 @@ bdb_cache_find_ndn(
                        ei.bei_nrdn.bv_len = ndn->bv_len - (ei.bei_nrdn.bv_val - ndn->bv_val);
                        bdb_cache_entryinfo_unlock( eip );
 
-                       rc = bdb_dn2id( be, txn, &ei.bei_nrdn, &ei, ctx );
+                       rc = bdb_dn2id( op, txn, &ei.bei_nrdn, &ei );
                        if (rc) {
                                bdb_cache_entryinfo_lock( eip );
                                *res = eip;
@@ -410,15 +409,14 @@ bdb_cache_find_ndn(
  * been linked into the cache.
  */
 static int
-bdb_cache_find_parent(
-       Backend *be,
+hdb_cache_find_parent(
+       Operation *op,
        DB_TXN *txn,
        ID id,
-       EntryInfo **res,
-       void *ctx
+       EntryInfo **res
 )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        EntryInfo ei, eip, *ei2 = NULL, *ein = NULL, *eir = NULL;
        ID parent;
        int rc;
@@ -427,7 +425,7 @@ bdb_cache_find_parent(
        ei.bei_kids = NULL;
 
        for (;;) {
-               rc = bdb_dn2id_parent( be, txn, &ei, &eip.bei_id, ctx );
+               rc = hdb_dn2id_parent( op, txn, &ei, &eip.bei_id );
                if ( rc ) break;
 
                /* Save the previous node, if any */
@@ -508,17 +506,16 @@ bdb_cache_find_parent(
 
 int
 bdb_cache_find_id(
-       Backend *be,
+       Operation *op,
        DB_TXN  *tid,
        ID                              id,
        EntryInfo       **eip,
        int             islocked,
        u_int32_t       locker,
-       DB_LOCK         *lock,
-       void            *ctx
+       DB_LOCK         *lock
 )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        Entry   *ep = NULL;
        int     rc = 0;
        EntryInfo ei;
@@ -540,10 +537,10 @@ bdb_cache_find_id(
        /* See if the ID exists in the database; add it to the cache if so */
        if ( !*eip ) {
 #ifndef BDB_HIER
-               rc = bdb_id2entry( be, tid, id, &ep );
+               rc = bdb_id2entry( op->o_bd, tid, id, &ep );
                if ( rc == 0 ) {
-                       rc = bdb_cache_find_ndn( be, tid,
-                               &ep->e_nname, eip, locker, ctx );
+                       rc = bdb_cache_find_ndn( op, tid,
+                               &ep->e_nname, eip, locker );
                        if ( *eip )
                                islocked = 1;
                        if ( rc ) {
@@ -552,7 +549,7 @@ bdb_cache_find_id(
                        }
                }
 #else
-               rc = bdb_cache_find_parent(be, tid, id, eip, ctx );
+               rc = hdb_cache_find_parent(op, tid, id, eip );
                if ( rc == 0 && *eip )
                        islocked = 1;
 #endif
@@ -564,7 +561,7 @@ bdb_cache_find_id(
                        rc = DB_NOTFOUND;
                } else if (!(*eip)->bei_e ) {
                        if (!ep) {
-                               rc = bdb_id2entry( be, tid, id, &ep );
+                               rc = bdb_id2entry( op->o_bd, tid, id, &ep );
                        }
                        if ( rc == 0 ) {
                                bdb_cache_entry_db_lock( bdb->bi_dbenv, locker,
index e3323b4d3a7c294a14b559200f213809a25b0825..635208d9f54a1adce373ec3237a734db43cdb76f 100644 (file)
@@ -36,7 +36,7 @@ bdb_compare( Operation *op, SlapReply *rs )
 
 dn2entry_retry:
        /* get entry */
-       rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &op->o_req_ndn, &ei, 1, locker, &lock, op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1, locker, &lock );
 
        switch( rs->sr_err ) {
        case DB_NOTFOUND:
index 3f02961e4e604ca89f2aa4f260764606c494e6b6..ef8dcd82d8ddcee381e3be2fe9d00b5c290ad6d3 100644 (file)
@@ -102,8 +102,8 @@ retry:      /* transaction retry */
        }
 
        /* get entry */
-       rs->sr_err = bdb_dn2entry( op->o_bd, ltid, &op->o_req_ndn, &ei, 1,
-               locker, &lock, op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
+               locker, &lock );
 
        switch( rs->sr_err ) {
        case 0:
@@ -124,8 +124,8 @@ retry:      /* transaction retry */
        if ( rs->sr_err == 0 ) {
                e = ei->bei_e;
                eip = ei->bei_parent;
-               bdb_cache_find_id( op->o_bd, ltid, eip->bei_id, &eip,
-                       0, locker, &plock, op->o_tmpmemctx );
+               bdb_cache_find_id( op, ltid, eip->bei_id, &eip,
+                       0, locker, &plock );
        } else {
                matched = ei->bei_e;
        }
@@ -360,8 +360,7 @@ retry:      /* transaction retry */
        }
 
        /* delete from dn2id */
-       rs->sr_err = bdb_dn2id_delete( op->o_bd, lt2, eip, e,
-               op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e );
        if ( rs->sr_err != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG ( OPERATION, ERR, 
index af5981f7cde99e8f272f2cc63b20c117c96e8ecd..ac20900f597b83fe48e8a592c33a0db843b61115 100644 (file)
 
 int
 bdb_dn2entry(
-       BackendDB       *be,
+       Operation *op,
        DB_TXN *tid,
        struct berval *dn,
        EntryInfo **e,
        int matched,
        u_int32_t locker,
-       DB_LOCK *lock,
-       void *ctx )
+       DB_LOCK *lock )
 {
        EntryInfo *ei = NULL;
        int rc;
@@ -42,7 +41,7 @@ bdb_dn2entry(
 
        *e = NULL;
 
-       rc = bdb_cache_find_ndn( be, tid, dn, &ei, locker, ctx );
+       rc = bdb_cache_find_ndn( op, tid, dn, &ei, locker );
        if ( rc ) {
                if ( matched && rc == DB_NOTFOUND ) {
                        /* Set the return value, whether we have its entry
@@ -50,23 +49,23 @@ bdb_dn2entry(
                         */
                        *e = ei;
                        if ( ei && ei->bei_id )
-                               bdb_cache_find_id( be, tid, ei->bei_id,
-                                       &ei, 1, locker, lock, ctx );
+                               bdb_cache_find_id( op, tid, ei->bei_id,
+                                       &ei, 1, locker, lock );
                        else if ( ei )
                                bdb_cache_entryinfo_unlock( ei );
                } else if ( ei ) {
                        bdb_cache_entryinfo_unlock( ei );
                }
        } else {
-               rc = bdb_cache_find_id( be, tid, ei->bei_id, &ei, 1,
-                       locker, lock, ctx );
+               rc = bdb_cache_find_id( op, tid, ei->bei_id, &ei, 1,
+                       locker, lock );
                if ( rc == 0 ) {
                        *e = ei;
                } else if ( matched && rc == DB_NOTFOUND ) {
                        /* always return EntryInfo */
                        ei = ei->bei_parent;
-                       bdb_cache_find_id( be, tid, ei->bei_id, &ei, 1,
-                               locker, lock, ctx );
+                       bdb_cache_find_id( op, tid, ei->bei_id, &ei, 1,
+                               locker, lock );
                        *e = ei;
                }
        }
index 8c6fed3bbe3d5afdf3c523984302d65bce7986d5..0dd6a20d3bed54ac323b50f3db05bee4368a08f6 100644 (file)
 #ifndef BDB_HIER
 int
 bdb_dn2id_add(
-       BackendDB       *be,
+       Operation *op,
        DB_TXN *txn,
        EntryInfo *eip,
-       Entry           *e,
-       void *ctx )
+       Entry           *e )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
        int             rc;
        DBT             key, data;
@@ -43,7 +42,7 @@ bdb_dn2id_add(
        key.size = e->e_nname.bv_len + 2;
        key.ulen = key.size;
        key.flags = DB_DBT_USERMEM;
-       buf = sl_malloc( key.size, ctx );
+       buf = op->o_tmpalloc( key.size, op->o_tmpmemctx );
        key.data = buf;
        buf[0] = DN_BASE_PREFIX;
        ptr.bv_val = buf + 1;
@@ -69,7 +68,7 @@ bdb_dn2id_add(
        }
 
 #ifndef BDB_MULTIPLE_SUFFIXES
-       if( !be_issuffix( be, &ptr )) {
+       if( !be_issuffix( op->o_bd, &ptr )) {
 #endif
                buf[0] = DN_SUBTREE_PREFIX;
                rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
@@ -87,7 +86,7 @@ bdb_dn2id_add(
                }
                
 #ifdef BDB_MULTIPLE_SUFFIXES
-       if( !be_issuffix( be, &ptr )) {
+       if( !be_issuffix( op->o_bd, &ptr )) {
 #endif
                dnParent( &ptr, &pdn );
        
@@ -97,7 +96,7 @@ bdb_dn2id_add(
                key.data = pdn.bv_val-1;
                ptr = pdn;
 
-               rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
+               rc = bdb_idl_insert_key( op->o_bd, db, txn, &key, e->e_id );
 
                if( rc != 0 ) {
 #ifdef NEW_LOGGING
@@ -114,13 +113,13 @@ bdb_dn2id_add(
 #ifndef BDB_MULTIPLE_SUFFIXES
        }
 
-       while( !be_issuffix( be, &ptr )) {
+       while( !be_issuffix( op->o_bd, &ptr )) {
 #else
        for (;;) {
 #endif
                ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
 
-               rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
+               rc = bdb_idl_insert_key( op->o_bd, db, txn, &key, e->e_id );
 
                if( rc != 0 ) {
 #ifdef NEW_LOGGING
@@ -135,7 +134,7 @@ bdb_dn2id_add(
                        break;
                }
 #ifdef BDB_MULTIPLE_SUFFIXES
-               if( be_issuffix( be, &ptr )) break;
+               if( be_issuffix( op->o_bd, &ptr )) break;
 #endif
                dnParent( &ptr, &pdn );
 
@@ -149,7 +148,7 @@ bdb_dn2id_add(
 #endif
 
 done:
-       sl_free( buf, ctx );
+       op->o_tmpfree( buf, op->o_tmpmemctx );
 #ifdef NEW_LOGGING
        LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
 #else
@@ -160,13 +159,12 @@ done:
 
 int
 bdb_dn2id_delete(
-       BackendDB       *be,
+       Operation *op,
        DB_TXN *txn,
        EntryInfo       *eip,
-       Entry           *e,
-       void *ctx )
+       Entry           *e )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
        int             rc;
        DBT             key;
@@ -183,7 +181,7 @@ bdb_dn2id_delete(
 
        DBTzero( &key );
        key.size = e->e_nname.bv_len + 2;
-       buf = sl_malloc( key.size, ctx );
+       buf = op->o_tmpalloc( key.size, op->o_tmpmemctx );
        key.data = buf;
        key.flags = DB_DBT_USERMEM;
        buf[0] = DN_BASE_PREFIX;
@@ -207,7 +205,7 @@ bdb_dn2id_delete(
        }
 
 #ifndef BDB_MULTIPLE_SUFFIXES
-       if( !be_issuffix( be, &ptr )) {
+       if( !be_issuffix( op->o_bd, &ptr )) {
 #endif
                buf[0] = DN_SUBTREE_PREFIX;
                rc = db->del( db, txn, &key, 0 );
@@ -225,7 +223,7 @@ bdb_dn2id_delete(
                }
 
 #ifdef BDB_MULTIPLE_SUFFIXES
-       if( !be_issuffix( be, &ptr )) {
+       if( !be_issuffix( op->o_bd, &ptr )) {
 #endif
                dnParent( &ptr, &pdn );
 
@@ -235,7 +233,7 @@ bdb_dn2id_delete(
                key.data = pdn.bv_val - 1;
                ptr = pdn;
 
-               rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
+               rc = bdb_idl_delete_key( op->o_bd, db, txn, &key, e->e_id );
 
                if( rc != 0 ) {
 #ifdef NEW_LOGGING
@@ -252,13 +250,13 @@ bdb_dn2id_delete(
 #ifndef BDB_MULTIPLE_SUFFIXES
        }
 
-       while( !be_issuffix( be, &ptr )) {
+       while( !be_issuffix( op->o_bd, &ptr )) {
 #else
        for (;;) {
 #endif
                ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
 
-               rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
+               rc = bdb_idl_delete_key( op->o_bd, db, txn, &key, e->e_id );
                if( rc != 0 ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG ( INDEX, ERR, 
@@ -272,7 +270,7 @@ bdb_dn2id_delete(
                        goto done;
                }
 #ifdef BDB_MULTIPLE_SUFFIXES
-               if( be_issuffix( be, &ptr )) break;
+               if( be_issuffix( op->o_bd, &ptr )) break;
 #endif
                dnParent( &ptr, &pdn );
 
@@ -286,7 +284,7 @@ bdb_dn2id_delete(
 #endif
 
 done:
-       sl_free( buf, ctx );
+       op->o_tmpfree( buf, op->o_tmpmemctx );
 #ifdef NEW_LOGGING
        LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
 #else
@@ -297,15 +295,14 @@ done:
 
 int
 bdb_dn2id(
-       BackendDB       *be,
+       Operation *op,
        DB_TXN *txn,
        struct berval   *dn,
-       EntryInfo *ei,
-       void *ctx )
+       EntryInfo *ei )
 {
        int             rc;
        DBT             key, data;
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
 
 #ifdef NEW_LOGGING
@@ -315,7 +312,7 @@ bdb_dn2id(
 #endif
        DBTzero( &key );
        key.size = dn->bv_len + 2;
-       key.data = sl_malloc( key.size, ctx );
+       key.data = op->o_tmpalloc( key.size, op->o_tmpmemctx );
        ((char *)key.data)[0] = DN_BASE_PREFIX;
        AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
 
@@ -346,7 +343,7 @@ bdb_dn2id(
 #endif
        }
 
-       sl_free( key.data, ctx );
+       op->o_tmpfree( key.data, op->o_tmpmemctx );
        return rc;
 }
 
@@ -371,7 +368,7 @@ bdb_dn2id_children(
 #endif
        DBTzero( &key );
        key.size = e->e_nname.bv_len + 2;
-       key.data = sl_malloc( key.size, op->o_tmpmemctx );
+       key.data = op->o_tmpalloc( key.size, op->o_tmpmemctx );
        ((char *)key.data)[0] = DN_ONE_PREFIX;
        AC_MEMCPY( &((char *)key.data)[1], e->e_nname.bv_val, key.size - 1 );
 
@@ -379,7 +376,7 @@ bdb_dn2id_children(
        if ( bdb->bi_idl_cache_size ) {
                rc = bdb_idl_cache_get( bdb, db, &key, NULL );
                if ( rc != LDAP_NO_SUCH_OBJECT ) {
-                       sl_free( key.data, op->o_tmpmemctx );
+                       op->o_tmpfree( key.data, op->o_tmpmemctx );
                        return rc;
                }
        }
@@ -393,7 +390,7 @@ bdb_dn2id_children(
        data.dlen = sizeof(id);
 
        rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags );
-       sl_free( key.data, op->o_tmpmemctx );
+       op->o_tmpfree( key.data, op->o_tmpmemctx );
 
 #ifdef NEW_LOGGING
        LDAP_LOG ( INDEX, DETAIL1, 
@@ -443,7 +440,7 @@ bdb_dn2idl(
        key.size = e->e_nname.bv_len + 2;
        key.ulen = key.size;
        key.flags = DB_DBT_USERMEM;
-       key.data = sl_malloc( key.size, op->o_tmpmemctx );
+       key.data = op->o_tmpalloc( key.size, op->o_tmpmemctx );
        ((char *)key.data)[0] = prefix;
        AC_MEMCPY( &((char *)key.data)[1], e->e_nname.bv_val, key.size - 1 );
 
@@ -473,7 +470,7 @@ bdb_dn2idl(
 #endif
        }
 
-       sl_free( key.data, op->o_tmpmemctx );
+       op->o_tmpfree( key.data, op->o_tmpmemctx );
        return rc;
 }
 #else  /* BDB_HIER */
@@ -588,28 +585,27 @@ int hdb_fix_dn(
  */
 int
 hdb_dn2id_add(
-       BackendDB       *be,
+       Operation       *op,
        DB_TXN *txn,
        EntryInfo       *eip,
-       Entry           *e,
-       void *ctx )
+       Entry           *e )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
        DBT             key, data;
        int             rc, rlen, nrlen;
        diskNode *d;
        char *ptr;
 
-       nrlen = dn_rdnlen( be, &e->e_nname );
+       nrlen = dn_rdnlen( op->o_bd, &e->e_nname );
        if (nrlen) {
-               rlen = dn_rdnlen( be, &e->e_name );
+               rlen = dn_rdnlen( op->o_bd, &e->e_name );
        } else {
                nrlen = e->e_nname.bv_len;
                rlen = e->e_name.bv_len;
        }
 
-       d = sl_malloc(sizeof(diskNode) + rlen + nrlen, ctx);
+       d = op->o_tmpalloc(sizeof(diskNode) + rlen + nrlen, op->o_tmpmemctx);
        d->entryID = e->e_id;
        d->nrdnlen = nrlen;
        ptr = lutil_strncopy( d->nrdn, e->e_nname.bv_val, nrlen );
@@ -642,20 +638,19 @@ hdb_dn2id_add(
                rc = db->put( db, txn, &key, &data, DB_NODUPDATA );
        }
 
-       sl_free( d, ctx );
+       op->o_tmpfree( d, op->o_tmpmemctx );
 
        return rc;
 }
 
 int
 hdb_dn2id_delete(
-       BackendDB       *be,
+       Operation       *op,
        DB_TXN *txn,
        EntryInfo       *eip,
-       Entry   *e,
-       void    *ctx )
+       Entry   *e )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
        DBT             key, data;
        DBC     *cursor;
@@ -682,7 +677,7 @@ hdb_dn2id_delete(
        rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
        if ( rc ) return rc;
 
-       d = sl_malloc( data.size, ctx );
+       d = op->o_tmpalloc( data.size, op->o_tmpmemctx );
        d->entryID = e->e_id;
        d->nrdnlen = BEI(e)->bei_nrdn.bv_len;
        strcpy( d->nrdn, BEI(e)->bei_nrdn.bv_val );
@@ -704,20 +699,19 @@ hdb_dn2id_delete(
                        rc = cursor->c_del( cursor, 0 );
        }
        cursor->c_close( cursor );
-       sl_free( d, ctx );
+       op->o_tmpfree( d, op->o_tmpmemctx );
 
        return rc;
 }
 
 int
 hdb_dn2id(
-       BackendDB       *be,
+       Operation       *op,
        DB_TXN *txn,
        struct berval   *in,
-       EntryInfo       *ei,
-       void *ctx )
+       EntryInfo       *ei )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
        DBT             key, data;
        DBC     *cursor;
@@ -726,7 +720,7 @@ hdb_dn2id(
        char    *ptr;
        ID idp = ei->bei_parent->bei_id;
 
-       nrlen = dn_rdnlen( be, in );
+       nrlen = dn_rdnlen( op->o_bd, in );
        if (!nrlen) nrlen = in->bv_len;
 
        DBTzero(&key);
@@ -743,7 +737,7 @@ hdb_dn2id(
        rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
        if ( rc ) return rc;
 
-       d = sl_malloc( data.size * 3, ctx );
+       d = op->o_tmpalloc( data.size * 3, op->o_tmpmemctx );
        d->nrdnlen = nrlen;
        ptr = lutil_strncopy( d->nrdn, in->bv_val, nrlen );
        *ptr = '\0';
@@ -759,20 +753,19 @@ hdb_dn2id(
                ei->bei_rdn.bv_val = ch_malloc( ei->bei_rdn.bv_len + 1 );
                strcpy( ei->bei_rdn.bv_val, ptr );
        }
-       sl_free( d, ctx );
+       op->o_tmpfree( d, op->o_tmpmemctx );
 
        return rc;
 }
 
 int
 hdb_dn2id_parent(
-       Backend *be,
+       Operation *op,
        DB_TXN *txn,
        EntryInfo *ei,
-       ID *idp,
-       void *ctx )
+       ID *idp )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB *db = bdb->bi_dn2id->bdi_db;
        DBT             key, data;
        DBC     *cursor;
@@ -794,7 +787,7 @@ hdb_dn2id_parent(
        if ( rc ) return rc;
 
        data.ulen = sizeof(diskNode) + (SLAP_LDAPDN_MAXLEN * 2);
-       d = sl_malloc( data.ulen, ctx );
+       d = op->o_tmpalloc( data.ulen, op->o_tmpmemctx );
        data.data = d;
 
        rc = cursor->c_get( cursor, &key, &data, DB_SET );
@@ -811,7 +804,7 @@ hdb_dn2id_parent(
                ptr = d->nrdn + ei->bei_nrdn.bv_len + 1;
                ber_str2bv( ptr, ei->bei_rdn.bv_len, 1, &ei->bei_rdn );
        }
-       sl_free( d, ctx );
+       op->o_tmpfree( d, op->o_tmpmemctx );
        return rc;
 }
 
@@ -883,7 +876,7 @@ struct dn2id_cookie {
        DBT key;
        DBT data;
        DBC *dbc;
-       void *ctx;
+       Operation *op;
 };
 
 static int
@@ -955,7 +948,8 @@ gotit:
                if ( cx->prefix == DN_SUBTREE_PREFIX ) {
                        ID *save, idcurs;
 
-                       save = sl_malloc( BDB_IDL_SIZEOF( cx->tmp ), cx->ctx );
+                       save = cx->op->o_tmpalloc( BDB_IDL_SIZEOF( cx->tmp ),
+                               cx->op->o_tmpmemctx );
                        BDB_IDL_CPY( save, cx->tmp );
                        bdb_idl_union( cx->ids, cx->tmp );
        
@@ -965,7 +959,7 @@ gotit:
                                cx->id = bdb_idl_next( save, &idcurs )) {
                                hdb_dn2idl_internal( cx );
                        }
-                       sl_free( save, cx->ctx );
+                       cx->op->o_tmpfree( save, cx->op->o_tmpmemctx );
                        cx->rc = 0;
                } else {
                        BDB_IDL_CPY( cx->ids, cx->tmp );
@@ -1006,7 +1000,7 @@ hdb_dn2idl(
                        DN_ONE_PREFIX;
        cx.ids = ids;
        cx.buf = stack;
-       cx.ctx = op->o_tmpmemctx;
+       cx.op = op;
 
        BDB_IDL_ZERO( ids );
        if ( cx.prefix == DN_SUBTREE_PREFIX ) {
index 66aad73ed6c1760a75067d6c98dad3ddf2afc738..c97feb26849b5ea10d58a7a64cbfa4cb3fd31284 100644 (file)
@@ -202,7 +202,7 @@ int bdb_entry_release(
                        bdb_unlocked_cache_return_entry_rw( &bdb->bi_cache, e, rw );
                } else {
                        bdb_cache_return_entry_rw( bdb->bi_dbenv, &bdb->bi_cache, e, rw, &boi->boi_lock );
-                       sl_free( boi, o->o_tmpmemctx );
+                       o->o_tmpfree( boi, o->o_tmpmemctx );
                        o->o_private = NULL;
                }
        } else {
@@ -272,7 +272,7 @@ int bdb_entry_get(
 
 dn2entry_retry:
        /* can we find entry */
-       rc = bdb_dn2entry( op->o_bd, txn, ndn, &ei, 0, locker, &lock, op->o_tmpmemctx );
+       rc = bdb_dn2entry( op, txn, ndn, &ei, 0, locker, &lock );
        switch( rc ) {
        case DB_NOTFOUND:
        case 0:
@@ -369,7 +369,7 @@ return_results:
                 * release it later??
                 */
                if ( op && !boi ) {
-                       boi = sl_calloc(1,sizeof(struct bdb_op_info),op->o_tmpmemctx);
+                       boi = op->o_tmpcalloc(1,sizeof(struct bdb_op_info),op->o_tmpmemctx);
                        boi->boi_lock = lock;
                        op->o_private = boi;
                }
index 950b52c27605863e266e7567c7fe201f997ae303..c4196495cbf6237fe231d8be60e2239d8f79a801 100644 (file)
@@ -174,7 +174,9 @@ static int indexer(
                return LDAP_OTHER;
        }
 
+#if 0  /* No longer needed, our frees are in order so nothing accumulates */
        mark = sl_mark(op->o_tmpmemctx);
+#endif
 
        if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) {
                rc = bdb_key_change( op->o_bd, db, txn, &presence_key, id, opid );
@@ -249,7 +251,9 @@ static int indexer(
        }
 
 done:
+#if 0
        sl_release( mark, op->o_tmpmemctx );
+#endif
        return rc;
 }
 
index f84f2074794edc75f1d7347f574b6734cb4e6349..387f9f5551c172cbc38ebd9a5900189f763d4ddb 100644 (file)
@@ -376,8 +376,8 @@ retry:      /* transaction retry */
        op->o_private = &opinfo;
 
        /* get entry or ancestor */
-       rs->sr_err = bdb_dn2entry( op->o_bd, ltid, &op->o_req_ndn, &ei, 1,
-               locker, &lock, op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
+               locker, &lock );
 
        if ( rs->sr_err != 0 ) {
 #ifdef NEW_LOGGING
index d414328e8c69332290589ab766ce3febaaba9325..412426f0b220c6d0a43607f32c8aeb8bf692b845 100644 (file)
@@ -137,8 +137,8 @@ retry:      /* transaction retry */
        op->o_private = &opinfo;
 
        /* get entry */
-       rs->sr_err = bdb_dn2entry( op->o_bd, ltid, &op->o_req_ndn, &ei, 1,
-               locker, &lock, op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
+               locker, &lock );
 
        switch( rs->sr_err ) {
        case 0:
@@ -273,8 +273,8 @@ retry:      /* transaction retry */
                 * children.
                 */
                eip = ei->bei_parent;
-               rs->sr_err = bdb_cache_find_id( op->o_bd, ltid,
-                       eip->bei_id, &eip, 0, locker, &plock, op->o_tmpmemctx );
+               rs->sr_err = bdb_cache_find_id( op, ltid,
+                       eip->bei_id, &eip, 0, locker, &plock );
 
                switch( rs->sr_err ) {
                case 0:
@@ -465,8 +465,8 @@ retry:      /* transaction retry */
                        /* newSuperior == entry being moved?, if so ==> ERROR */
                        /* Get Entry with dn=newSuperior. Does newSuperior exist? */
 
-                       rs->sr_err = bdb_dn2entry( op->o_bd, ltid, np_ndn,
-                               &neip, 0, locker, &nplock, op->o_tmpmemctx );
+                       rs->sr_err = bdb_dn2entry( op, ltid, np_ndn,
+                               &neip, 0, locker, &nplock );
 
                        switch( rs->sr_err ) {
                        case 0: np = neip->bei_e;
@@ -669,8 +669,7 @@ retry:      /* transaction retry */
 
        /* Shortcut the search */
        nei = neip ? neip : eip;
-       rs->sr_err = bdb_cache_find_ndn ( op->o_bd, ltid, &new_ndn,
-               &nei, locker, op->o_tmpmemctx );
+       rs->sr_err = bdb_cache_find_ndn ( op, ltid, &new_ndn, &nei, locker );
        if ( nei ) bdb_cache_entryinfo_unlock( nei );
        switch( rs->sr_err ) {
        case DB_LOCK_DEADLOCK:
@@ -775,8 +774,7 @@ retry:      /* transaction retry */
        e = &dummy;
 
        /* delete old one */
-       rs->sr_err = bdb_dn2id_delete( op->o_bd, lt2, eip, e,
-               op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e );
        if ( rs->sr_err != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG ( OPERATION, ERR, 
@@ -813,8 +811,7 @@ retry:      /* transaction retry */
        new_ndn.bv_val = NULL;
 
        /* add new one */
-       rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, neip ? neip : eip, e,
-               op->o_tmpmemctx );
+       rs->sr_err = bdb_dn2id_add( op, lt2, neip ? neip : eip, e );
        if ( rs->sr_err != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG ( OPERATION, ERR, 
index 181447ca900a86e05c2faaa65e99161dbc976886..a3c0ebf408ccd3a65d4fcb88461905b93561aaeb 100644 (file)
@@ -150,7 +150,7 @@ retry:      /* transaction retry */
        op->o_private = &opinfo;
 
        /* get entry */
-       rc = bdb_dn2entry( op->o_bd, ltid, &ndn, &ei, 0 , locker, &lock, op->o_tmpmemctx );
+       rc = bdb_dn2entry( op, ltid, &ndn, &ei, 0 , locker, &lock );
 
        switch(rc) {
        case DB_LOCK_DEADLOCK:
index bbd31ece7432ff69ac8a31f533fd0bc30dc0afd8..27e10d5f4ca72ea191ff8479a3387e5e6bfff270 100644 (file)
@@ -50,9 +50,9 @@ bdb_db_cache(
  */
 #define bdb_dn2entry                           BDB_SYMBOL(dn2entry)
 
-int bdb_dn2entry LDAP_P(( BackendDB *be, DB_TXN *tid,
+int bdb_dn2entry LDAP_P(( Operation *op, DB_TXN *tid,
        struct berval *dn, EntryInfo **e, int matched,
-       u_int32_t locker, DB_LOCK *lock, void *ctx));
+       u_int32_t locker, DB_LOCK *lock ));
 
 /*
  * dn2id.c
@@ -64,25 +64,22 @@ int bdb_dn2entry LDAP_P(( BackendDB *be, DB_TXN *tid,
 #define bdb_dn2idl                                     BDB_SYMBOL(dn2idl)
 
 int bdb_dn2id(
-       BackendDB *be,
+       Operation *op,
        DB_TXN *tid,
        struct berval *dn,
-       EntryInfo *ei,
-       void *ctx );
+       EntryInfo *ei );
 
 int bdb_dn2id_add(
-       BackendDB *be,
+       Operation *op,
        DB_TXN *tid,
        EntryInfo *eip,
-       Entry *e,
-       void *ctx );
+       Entry *e );
 
 int bdb_dn2id_delete(
-       BackendDB *be,
+       Operation *op,
        DB_TXN *tid,
        EntryInfo *eip,
-       Entry *e,
-       void *ctx );
+       Entry *e );
 
 int bdb_dn2id_children(
        Operation *op,
@@ -101,11 +98,10 @@ int bdb_dn2idl(
 #define bdb_fix_dn                                     BDB_SYMBOL(fix_dn)
 
 int bdb_dn2id_parent(
-       Backend *be,
+       Operation *op,
        DB_TXN *txn,
        EntryInfo *ei,
-       ID *idp,
-       void *ctx );
+       ID *idp );
 
 int bdb_dup_compare(
        DB *db,
@@ -444,22 +440,20 @@ int bdb_cache_modify(
        DB_LOCK *lock
 );
 int bdb_cache_find_ndn(
-       Backend *be,
+       Operation *op,
        DB_TXN  *txn,
        struct berval   *ndn,
        EntryInfo       **res,
-       u_int32_t       locker,
-       void    *ctx
+       u_int32_t       locker
 );
 int bdb_cache_find_id(
-       Backend *be,
+       Operation *op,
        DB_TXN  *tid,
        ID              id,
        EntryInfo **eip,
        int     islocked,
        u_int32_t       locker,
-       DB_LOCK         *lock,
-       void    *ctx
+       DB_LOCK         *lock
 );
 int bdb_cache_delete(
        Cache   *cache,
index ea9dcfd86d533bd9119b18c53b98591f000017d3..e79c5b0d21977b4ad8c0e9ae6b6a4b578d9c764f 100644 (file)
@@ -43,8 +43,7 @@ bdb_referrals( Operation *op, SlapReply *rs )
 
 dn2entry_retry:
        /* get entry */
-       rc = bdb_dn2entry( op->o_bd, NULL, &op->o_req_ndn, &ei, 1, locker,
-               &lock, op->o_tmpmemctx );
+       rc = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1, locker, &lock );
 
        e = ei->bei_e;
        switch(rc) {
@@ -118,7 +117,7 @@ dn2entry_retry:
 
                LOCK_ID_FREE ( bdb->bi_dbenv, locker );
                if (rs->sr_matched) {
-                       sl_free( (char *)rs->sr_matched, op->o_tmpmemctx );
+                       op->o_tmpfree( (char *)rs->sr_matched, op->o_tmpmemctx );
                        rs->sr_matched = NULL;
                }
                return rc;
index 6acb9303c3b28c57988d52744094fe299de53fa1..a810ce56e399dfad5db0c15b0494a7296d4394f5 100644 (file)
@@ -86,8 +86,8 @@ static Entry * deref_base (
                        break;
                }
 
-               rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &ndn, &ei,
-                       0, locker, &lockr, op->o_tmpmemctx );
+               rs->sr_err = bdb_dn2entry( op, NULL, &ndn, &ei,
+                       0, locker, &lockr );
 
                if ( ei ) e = ei->bei_e;
                else    e = NULL;
@@ -203,8 +203,8 @@ static int search_aliases(
                        ida = bdb_idl_next(curscop, &cursora))
                {
                        ei = NULL;
-                       rs->sr_err = bdb_cache_find_id(op->o_bd, NULL,
-                               ida, &ei, 0, locker, &lockr, op->o_tmpmemctx );
+                       rs->sr_err = bdb_cache_find_id(op, NULL,
+                               ida, &ei, 0, locker, &lockr );
                        if (rs->sr_err != LDAP_SUCCESS) {
                                continue;
                        }
@@ -269,8 +269,8 @@ nextido:
                 * Set the name so that the scope's IDL can be retrieved.
                 */
                ei = NULL;
-               rs->sr_err = bdb_cache_find_id(op->o_bd, NULL, ido, &ei,
-                       0, locker, &locka, op->o_tmpmemctx );
+               rs->sr_err = bdb_cache_find_id(op, NULL, ido, &ei,
+                       0, locker, &locka );
                if (rs->sr_err != LDAP_SUCCESS) goto nextido;
                e = ei->bei_e;
        }
@@ -507,8 +507,8 @@ int bdb_search( Operation *op, SlapReply *rs )
        } else {
 dn2entry_retry:
                /* get entry with reader lock */
-               rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &sop->o_req_ndn, &ei,
-                       1, locker, &lock, op->o_tmpmemctx );
+               rs->sr_err = bdb_dn2entry( op, NULL, &sop->o_req_ndn, &ei,
+                       1, locker, &lock );
        }
 
        switch(rs->sr_err) {
@@ -910,8 +910,8 @@ loop_begin:
 id2entry_retry:
                        /* get the entry with reader lock */
                        ei = NULL;
-                       rs->sr_err = bdb_cache_find_id( op->o_bd, NULL,
-                               id, &ei, 0, locker, &lock, op->o_tmpmemctx );
+                       rs->sr_err = bdb_cache_find_id( op, NULL,
+                               id, &ei, 0, locker, &lock );
 
                        if (rs->sr_err == LDAP_BUSY) {
                                rs->sr_text = "ldap server busy";
index 681b13fdb9a109cca88c8dec0afde863764dc762..69aeea22aea59b9ae632faf1da58688638f50679 100644 (file)
@@ -125,8 +125,13 @@ Entry* bdb_tool_entry_get( BackendDB *be, ID id )
 #else
        {
                EntryInfo *ei = NULL;
-               rc = bdb_cache_find_id( be, NULL, id, &ei, 0, 0,
-                       NULL, NULL );
+               Operation op = {0};
+
+               op.o_bd = be;
+               op.o_tmpmemctx = NULL;
+               op.o_tmpmfuncs = &ch_mfuncs;
+
+               rc = bdb_cache_find_id( &op, NULL, id, &ei, 0, 0, NULL );
                if ( rc == LDAP_SUCCESS )
                        e = ei->bei_e;
        }
@@ -135,33 +140,33 @@ Entry* bdb_tool_entry_get( BackendDB *be, ID id )
 }
 
 static int bdb_tool_next_id(
-       BackendDB *be,
+       Operation *op,
        DB_TXN *tid,
        Entry *e,
        struct berval *text,
        int hole,
        u_int32_t locker )
 {
-       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        struct berval dn = e->e_nname;
        struct berval pdn;
        EntryInfo *ei = NULL;
        int rc;
 
-       rc = bdb_cache_find_ndn( be, tid, &dn, &ei, locker, NULL );
+       rc = bdb_cache_find_ndn( op, tid, &dn, &ei, locker );
        if ( ei ) bdb_cache_entryinfo_unlock( ei );
        if ( rc == DB_NOTFOUND ) {
-               if ( be_issuffix( be, &dn ) ) {
+               if ( be_issuffix( op->o_bd, &dn ) ) {
                        pdn = slap_empty_bv;
                } else {
                        dnParent( &dn, &pdn );
                        e->e_nname = pdn;
-                       rc = bdb_tool_next_id( be, tid, e, text, 1, locker );
+                       rc = bdb_tool_next_id( op, tid, e, text, 1, locker );
                        if ( rc ) {
                                return rc;
                        }
                }
-               rc = bdb_next_id( be, tid, &e->e_id );
+               rc = bdb_next_id( op->o_bd, tid, &e->e_id );
                if ( rc ) {
                        snprintf( text->bv_val, text->bv_len,
                                "next_id failed: %s (%d)",
@@ -176,7 +181,7 @@ static int bdb_tool_next_id(
                        return rc;
                }
                e->e_nname = dn;
-               rc = bdb_dn2id_add( be, tid, ei, e, NULL );
+               rc = bdb_dn2id_add( op, tid, ei, e );
                if ( rc ) {
                        snprintf( text->bv_val, text->bv_len, 
                                "dn2id_add failed: %s (%d)",
@@ -262,9 +267,13 @@ ID bdb_tool_entry_put(
                return NOID;
        }
 
+       op.o_bd = be;
+       op.o_tmpmemctx = NULL;
+       op.o_tmpmfuncs = &ch_mfuncs;
+
        locker = TXN_ID( tid );
        /* add dn2id indices */
-       rc = bdb_tool_next_id( be, tid, e, text, 0, locker );
+       rc = bdb_tool_next_id( &op, tid, e, text, 0, locker );
        if( rc != 0 ) {
                goto done;
        }
@@ -285,9 +294,6 @@ ID bdb_tool_entry_put(
                goto done;
        }
 
-       op.o_bd = be;
-       op.o_tmpmemctx = NULL;
-       op.o_tmpmfuncs = &ch_mfuncs;
        rc = bdb_index_entry_add( &op, tid, e );
        if( rc != 0 ) {
                snprintf( text->bv_val, text->bv_len,
@@ -402,9 +408,13 @@ int bdb_tool_entry_reindex(
                (long) id, e->e_dn, 0 );
 #endif
 
+       op.o_bd = be;
+       op.o_tmpmemctx = NULL;
+       op.o_tmpmfuncs = &ch_mfuncs;
+
 #ifndef BDB_HIER
        /* add dn2id indices */
-       rc = bdb_dn2id_add( be, tid, NULL, e, NULL );
+       rc = bdb_dn2id_add( &op, tid, NULL, e );
        if( rc != 0 && rc != DB_KEYEXIST ) {
 #ifdef NEW_LOGGING
                LDAP_LOG ( TOOLS, ERR, 
@@ -419,9 +429,6 @@ int bdb_tool_entry_reindex(
        }
 #endif
 
-       op.o_bd = be;
-       op.o_tmpmemctx = NULL;
-       op.o_tmpmfuncs = &ch_mfuncs;
        rc = bdb_index_entry_add( &op, tid, e );
 
 done: