From eed30c335e119a3c4d8da7d5b0208d6fdaba64b4 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 24 Nov 2004 05:07:17 +0000 Subject: [PATCH] Sync with HEAD: updated Debug labels, unifdef NEW_LOGGING, add BDB 4.3 support fix ITS#3356, 3358, 3385 (back-bdb part), ctxcsn memleaks --- servers/slapd/back-bdb/add.c | 167 +++--------- servers/slapd/back-bdb/back-bdb.h | 5 +- servers/slapd/back-bdb/bind.c | 39 +-- servers/slapd/back-bdb/cache.c | 118 ++++---- servers/slapd/back-bdb/ctxcsn.c | 31 +-- servers/slapd/back-bdb/delete.c | 209 ++++----------- servers/slapd/back-bdb/error.c | 8 +- servers/slapd/back-bdb/filterindex.c | 299 --------------------- servers/slapd/back-bdb/id2entry.c | 2 - servers/slapd/back-bdb/init.c | 141 ++-------- servers/slapd/back-bdb/modify.c | 216 +++------------ servers/slapd/back-bdb/modrdn.c | 385 ++++++--------------------- servers/slapd/back-bdb/operational.c | 3 +- servers/slapd/back-bdb/proto-bdb.h | 8 +- servers/slapd/back-bdb/referral.c | 9 +- servers/slapd/back-bdb/search.c | 106 ++------ servers/slapd/back-bdb/tools.c | 178 +++---------- 17 files changed, 396 insertions(+), 1528 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 6174a51616..59080c4e24 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -53,13 +53,8 @@ bdb_add(Operation *op, SlapReply *rs ) LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS]; int num_ctrls = 0; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ARGS, "==> bdb_add: %s\n", - op->oq_add.rs_e->e_name.bv_val, 0, 0 ); -#else - Debug(LDAP_DEBUG_ARGS, "==> bdb_add: %s\n", + Debug(LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(bdb_add) ": %s\n", op->oq_add.rs_e->e_name.bv_val, 0, 0); -#endif ctrls[num_ctrls] = 0; @@ -67,15 +62,9 @@ bdb_add(Operation *op, SlapReply *rs ) rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e, NULL, &rs->sr_text, textbuf, textlen ); if ( rs->sr_err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_add: entry failed schema check: %s (%d)\n", - rs->sr_text, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_add: entry failed schema check: %s (%d)\n", - rs->sr_text, rs->sr_err, 0 ); -#endif + LDAP_XSTRING(bdb_add) ": entry failed schema check: " + "%s (%d)\n", rs->sr_text, rs->sr_err, 0 ); goto return_results; } @@ -89,13 +78,9 @@ bdb_add(Operation *op, SlapReply *rs ) */ rs->sr_err = bdb_next_id( op->o_bd, NULL, &op->oq_add.rs_e->e_id ); if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_add: next_id failed (%d)\n", rs->sr_err, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_add: next_id failed (%d)\n", rs->sr_err, 0, 0 ); -#endif + LDAP_XSTRING(bdb_add) ": next_id failed (%d)\n", + rs->sr_err, 0, 0 ); rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -126,15 +111,9 @@ retry: /* transaction retry */ bdb->bi_db_opflags ); rs->sr_text = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_add: txn_begin failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_add: txn_begin failed: %s (%d)\n", + LDAP_XSTRING(bdb_add) ": txn_begin failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -189,13 +168,9 @@ retry: /* transaction retry */ : NULL; bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p ); p = NULL; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, "bdb_add: parent does not exist\n", - 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: parent does not exist\n", - 0, 0, 0 ); -#endif + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": parent " + "does not exist\n", 0, 0, 0 ); rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); @@ -218,13 +193,9 @@ retry: /* transaction retry */ goto retry; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_add: no write access to parent\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_add: no write access to parent\n", 0, 0, 0 ); -#endif + LDAP_XSTRING(bdb_add) ": no write access " + "to parent\n", 0, 0, 0 ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; rs->sr_text = "no write access to parent"; goto return_results;; @@ -233,46 +204,32 @@ retry: /* transaction retry */ #ifdef BDB_SUBENTRIES if ( is_entry_subentry( p ) ) { /* parent is a subentry, don't allow add */ -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_add: parent is subentry\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is subentry\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": parent is subentry\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_OBJECT_CLASS_VIOLATION; rs->sr_text = "parent is a subentry"; goto return_results;; } #endif -#ifdef BDB_ALIASES if ( is_entry_alias( p ) ) { /* parent is an alias, don't allow add */ -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_add: parent is alias\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is alias\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": parent is alias\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_ALIAS_PROBLEM; rs->sr_text = "parent is an alias"; goto return_results;; } -#endif if ( is_entry_referral( p ) ) { /* parent is a referral, don't allow add */ rs->sr_matched = p->e_name.bv_val; rs->sr_ref = get_entry_referrals( op, p ); -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_add: parent is referral\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is referral\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": parent is referral\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); @@ -304,14 +261,10 @@ retry: /* transaction retry */ if ((( !be_isroot( op ) && !be_shadow_update(op) ) || pdn.bv_len > 0 ) && !is_entry_glue( op->oq_add.rs_e )) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, "bdb_add: %s denied\n", - pdn.bv_len == 0 ? "suffix" : "entry at root", 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: %s denied\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": %s denied\n", pdn.bv_len == 0 ? "suffix" : "entry at root", 0, 0 ); -#endif rs->sr_err = LDAP_NO_SUCH_OBJECT; goto return_results; } @@ -335,13 +288,9 @@ retry: /* transaction retry */ goto retry; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_add: no write access to entry\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: no write access to entry\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": no write access to entry\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_INSUFFICIENT_ACCESS; rs->sr_text = "no write access to entry"; goto return_results;; @@ -352,15 +301,9 @@ retry: /* transaction retry */ bdb->bi_db_opflags ); rs->sr_text = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_add: txn_begin(2) failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_add: txn_begin(2) failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif + LDAP_XSTRING(bdb_add) ": txn_begin(2) failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -369,14 +312,9 @@ retry: /* transaction retry */ /* dn2id index */ 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, - "bdb_add: dn2id_add failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: dn2id_add failed: %s (%d)\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": dn2id_add failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: @@ -394,12 +332,9 @@ retry: /* transaction retry */ /* id2entry index */ rs->sr_err = bdb_id2entry_add( op->o_bd, lt2, op->oq_add.rs_e ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, "bdb_add: id2entry_add failed\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: id2entry_add failed\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": id2entry_add failed\n", 0, 0, 0 ); -#endif switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -414,13 +349,9 @@ retry: /* transaction retry */ /* attribute indexes */ rs->sr_err = bdb_index_entry_add( op, lt2, op->oq_add.rs_e ); if ( rs->sr_err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_add: index_entry_add failed\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: index_entry_add failed\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": index_entry_add failed\n", 0, 0, 0 ); -#endif switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -457,13 +388,9 @@ retry: /* transaction retry */ if ( slap_read_controls( op, rs, op->oq_add.rs_e, &slap_post_read_bv, postread_ctrl ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_add: post-read failed!\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_add: post-read failed!\n", 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_add) ": post-read " + "failed!\n", 0, 0, 0 ); goto return_results; } } @@ -506,15 +433,11 @@ retry: /* transaction retry */ LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) { rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_ADD ); if ( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_add: persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_add: persistent search failed (%d,%d)\n", + LDAP_XSTRING(bdb_add) + ": persistent search failed " + "(%d,%d)\n", rc, rs->sr_err, 0 ); -#endif } } ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); @@ -531,27 +454,17 @@ retry: /* transaction retry */ op->o_private = NULL; if ( rs->sr_err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, "bdb_add: %s : %s (%d)\n", - rs->sr_text, db_strerror(rs->sr_err), rs->sr_err ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": %s : %s (%d)\n", rs->sr_text, db_strerror(rs->sr_err), rs->sr_err ); -#endif rs->sr_err = LDAP_OTHER; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_add: added%s id=%08lx dn=\"%s\"\n", + Debug(LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_add) ": added%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", op->oq_add.rs_e->e_id, op->oq_add.rs_e->e_dn ); -#else - Debug(LDAP_DEBUG_TRACE, "bdb_add: added%s id=%08lx dn=\"%s\"\n", - op->o_noop ? " (no-op)" : "", - op->oq_add.rs_e->e_id, op->oq_add.rs_e->e_dn ); -#endif rs->sr_text = NULL; if( num_ctrls ) rs->sr_ctrls = ctrls; @@ -572,8 +485,8 @@ done: } if( postread_ctrl != NULL ) { - slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx ); - slap_sl_free( *postread_ctrl, &op->o_tmpmemctx ); + slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx ); + slap_sl_free( *postread_ctrl, op->o_tmpmemctx ); } return rs->sr_err; } diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 3dcbc6de96..7d8b389c6f 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -23,6 +23,8 @@ LDAP_BEGIN_DECL +#define DB_VERSION_FULL ((DB_VERSION_MAJOR << 24) | (DB_VERSION_MINOR << 16) | DB_VERSION_PATCH) + #define BDB_SUBENTRIES 1 #define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX @@ -39,8 +41,6 @@ LDAP_BEGIN_DECL #define BDB_MAX_ADD_LOOP 30 -#define BDB_ALIASES 1 - #ifdef BDB_SUBDIRS #define BDB_TMP_SUBDIR "tmp" #define BDB_LG_SUBDIR "log" @@ -124,6 +124,7 @@ typedef struct bdb_entry_info { typedef struct bdb_cache { int c_maxsize; int c_cursize; + int c_eiused; /* EntryInfo's in use */ EntryInfo c_dntree; EntryInfo *c_eifree; /* free list */ Avlnode *c_idtree; diff --git a/servers/slapd/back-bdb/bind.c b/servers/slapd/back-bdb/bind.c index 9739773aea..580e9806af 100644 --- a/servers/slapd/back-bdb/bind.c +++ b/servers/slapd/back-bdb/bind.c @@ -43,13 +43,9 @@ bdb_bind( Operation *op, SlapReply *rs ) u_int32_t locker; DB_LOCK lock; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ARGS, - "==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ARGS, - "==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0); -#endif + "==> " LDAP_XSTRING(bdb_bind) ": dn: %s\n", + op->o_req_dn.bv_val, 0, 0); /* allow noauth binds */ if ( op->oq_bind.rb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op )) { @@ -112,46 +108,23 @@ dn2entry_retry: #ifdef BDB_SUBENTRIES if ( is_entry_subentry( e ) ) { /* entry is an subentry, don't allow bind */ -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_bind: entry is subentry\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "entry is subentry\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_INVALID_CREDENTIALS; goto done; } #endif -#ifdef BDB_ALIASES if ( is_entry_alias( e ) ) { /* entry is an alias, don't allow bind */ -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_bind: entry is alias\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 ); -#endif - -#if 1 rs->sr_err = LDAP_INVALID_CREDENTIALS; -#else - rs->sr_err = LDAP_ALIAS_PROBLEM; - rs->sr_text = "entry is alias"; -#endif goto done; } -#endif if ( is_entry_referral( e ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_bind: entry is referral\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_INVALID_CREDENTIALS; goto done; } @@ -161,20 +134,12 @@ dn2entry_retry: rs->sr_err = access_allowed( op, e, password, NULL, ACL_AUTH, NULL ); if ( ! rs->sr_err ) { -#if 1 rs->sr_err = LDAP_INVALID_CREDENTIALS; -#else - rs->sr_err = LDAP_INSUFFICIENT_ACCESS; -#endif goto done; } if ( (a = attr_find( e->e_attrs, password )) == NULL ) { -#if 1 rs->sr_err = LDAP_INVALID_CREDENTIALS; -#else - rs->sr_err = LDAP_INAPPROPRIATE_AUTH; -#endif goto done; } diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 3bcb11a1ed..62f5450d40 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -26,7 +26,11 @@ #include "back-bdb.h" -static int bdb_cache_delete_internal(Cache *cache, EntryInfo *e); +#ifdef BDB_HIER +#define bdb_cache_lru_add hdb_cache_lru_add +#endif + +static int bdb_cache_delete_internal(Cache *cache, EntryInfo *e, int decr); #ifdef LDAP_DEBUG static void bdb_lru_print(Cache *cache); #endif @@ -252,6 +256,7 @@ bdb_entryinfo_add_internal( ei->bei_rdn.bv_val = NULL; #endif } else { + bdb->bi_cache.c_eiused++; ber_dupbv( &ei2->bei_nrdn, &ei->bei_nrdn ); avl_insert( &ei->bei_parent->bei_kids, ei2, bdb_rdn_cmp, avl_dup_error ); @@ -384,6 +389,7 @@ hdb_cache_find_parent( ei.bei_id = id; ei.bei_kids = NULL; + ei.bei_ckids = 0; for (;;) { rc = hdb_dn2id_parent( op, txn, &ei, &eip.bei_id ); @@ -398,6 +404,8 @@ hdb_cache_find_parent( ein->bei_kids = ei.bei_kids; ein->bei_nrdn = ei.bei_nrdn; ein->bei_rdn = ei.bei_rdn; + ein->bei_ckids = ei.bei_ckids; + ei.bei_ckids = 0; /* This node is not fully connected yet */ ein->bei_state = CACHE_ENTRY_NOT_LINKED; @@ -419,6 +427,7 @@ hdb_cache_find_parent( bdb_cache_entryinfo_lock( ein ); avl_insert( &ein->bei_kids, (caddr_t)ei2, bdb_rdn_cmp, avl_dup_error ); + ein->bei_ckids++; bdb_cache_entryinfo_unlock( ein ); } @@ -442,6 +451,7 @@ hdb_cache_find_parent( } else { ei2 = &bdb->bi_cache.c_dntree; } + bdb->bi_cache.c_eiused++; ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); /* Got the parent, link in and we're done. */ @@ -450,6 +460,7 @@ hdb_cache_find_parent( ein->bei_parent = ei2; avl_insert( &ei2->bei_kids, (caddr_t)ein, bdb_rdn_cmp, avl_dup_error); + ei2->bei_ckids++; bdb_cache_entryinfo_unlock( ei2 ); bdb_cache_entryinfo_lock( eir ); @@ -461,6 +472,7 @@ hdb_cache_find_parent( } ei.bei_kids = NULL; ei.bei_id = eip.bei_id; + ei.bei_ckids = 1; avl_insert( &ei.bei_kids, (caddr_t)ein, bdb_rdn_cmp, avl_dup_error ); } @@ -537,11 +549,14 @@ bdb_cache_lru_add( */ if ( bdb_cache_entry_db_lock( bdb->bi_dbenv, bdb->bi_cache.c_locker, elru, 1, 1, lockp ) == 0 ) { + int stop = 0; + /* If there's no entry, or this node is in * the process of linking into the cache, - * skip it. + * or this node is being deleted, skip it. */ - if ( !elru->bei_e || (elru->bei_state & CACHE_ENTRY_NOT_LINKED) ) { + if ( !elru->bei_e || (elru->bei_state & + ( CACHE_ENTRY_NOT_LINKED | CACHE_ENTRY_DELETED ))) { bdb_cache_entry_db_unlock( bdb->bi_dbenv, lockp ); continue; } @@ -549,10 +564,13 @@ bdb_cache_lru_add( elru->bei_e->e_private = NULL; bdb_entry_return( elru->bei_e ); elru->bei_e = NULL; - bdb_cache_entry_db_unlock( bdb->bi_dbenv, lockp ); + ldap_pvt_thread_rdwr_wlock( &bdb->bi_cache.c_rwlock ); --bdb->bi_cache.c_cursize; - if (bdb->bi_cache.c_cursize < bdb->bi_cache.c_maxsize) - break; + if (bdb->bi_cache.c_cursize <= bdb->bi_cache.c_maxsize) + stop = 1; + ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); + bdb_cache_entry_db_unlock( bdb->bi_dbenv, lockp ); + if (stop) break; } } } @@ -595,7 +613,7 @@ bdb_cache_find_id( { struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; Entry *ep = NULL; - int rc = 0; + int rc = 0, load = 0; EntryInfo ei = { 0 }; ei.bei_id = id; @@ -658,7 +676,6 @@ again: ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock ); if ( (*eip)->bei_state & CACHE_ENTRY_DELETED ) { rc = DB_NOTFOUND; } else { - int load = 0; /* Make sure only one thread tries to load the entry */ load1: if ( !(*eip)->bei_e && !((*eip)->bei_state & CACHE_ENTRY_LOADING)) { load = 1; @@ -763,17 +780,30 @@ load1: if ( !(*eip)->bei_e && !((*eip)->bei_state & CACHE_ENTRY_LOADING)) { bdb_entry_return( ep ); } if ( rc == 0 ) { - /* set lru mutex */ + + if ( load ) { + ldap_pvt_thread_rdwr_wlock( &bdb->bi_cache.c_rwlock ); + bdb->bi_cache.c_cursize++; + ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); + } + ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex ); - /* if entry is on LRU list, remove from old spot */ - if ( (*eip)->bei_lrunext || (*eip)->bei_lruprev ) { - LRU_DELETE( &bdb->bi_cache, *eip ); + + /* If the LRU list has only one entry and this is it, it + * doesn't need to be added again. + */ + if ( bdb->bi_cache.c_lruhead == bdb->bi_cache.c_lrutail && + bdb->bi_cache.c_lruhead == *eip ) { + ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.lru_mutex ); } else { - /* if entry is new, bump cache size */ - bdb->bi_cache.c_cursize++; + + /* if entry is on LRU list, remove from old spot */ + if ( (*eip)->bei_lrunext || (*eip)->bei_lruprev ) { + LRU_DELETE( &bdb->bi_cache, *eip ); + } + /* lru_mutex is unlocked for us */ + bdb_cache_lru_add( bdb, locker, *eip ); } - /* lru_mutex is unlocked for us */ - bdb_cache_lru_add( bdb, locker, *eip ); } return rc; @@ -850,15 +880,16 @@ bdb_cache_add( if (eip->bei_parent) { eip->bei_parent->bei_state &= ~CACHE_ENTRY_NO_GRANDKIDS; } + bdb_cache_entryinfo_unlock( eip ); /* set lru mutex */ ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex ); ++bdb->bi_cache.c_cursize; + ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); + /* lru_mutex is unlocked for us */ bdb_cache_lru_add( bdb, locker, new ); - bdb_cache_entryinfo_unlock( eip ); - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); return rc; } @@ -997,30 +1028,15 @@ bdb_cache_delete( return rc; } - /* set cache write lock */ - ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock ); - - /* Lock the parent's kids tree */ - bdb_cache_entryinfo_lock( ei->bei_parent ); - -#ifdef NEW_LOGGING - LDAP_LOG( CACHE, ENTRY, - "bdb_cache_delete: delete %ld.\n", e->e_id, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_delete( %ld )\n", e->e_id, 0, 0 ); -#endif /* set lru mutex */ ldap_pvt_thread_mutex_lock( &cache->lru_mutex ); - rc = bdb_cache_delete_internal( cache, e->e_private ); + rc = bdb_cache_delete_internal( cache, e->e_private, 1 ); /* free lru mutex */ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex ); - /* free cache write lock */ - ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); - bdb_cache_entryinfo_unlock( ei->bei_parent ); - /* Leave entry info locked */ return( rc ); @@ -1029,13 +1045,13 @@ bdb_cache_delete( void bdb_cache_delete_cleanup( Cache *cache, - Entry *e ) + EntryInfo *ei ) { - EntryInfo *ei = BEI(e); - - ei->bei_e = NULL; - e->e_private = NULL; - bdb_entry_return( e ); + if ( ei->bei_e ) { + ei->bei_e->e_private = NULL; + bdb_entry_return( ei->bei_e ); + ei->bei_e = NULL; + } free( ei->bei_nrdn.bv_val ); ei->bei_nrdn.bv_val = NULL; @@ -1060,13 +1076,20 @@ bdb_cache_delete_cleanup( static int bdb_cache_delete_internal( Cache *cache, - EntryInfo *e ) + EntryInfo *e, + int decr ) { int rc = 0; /* return code */ + /* set cache write lock */ + ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock ); + + /* Lock the parent's kids tree */ + bdb_cache_entryinfo_lock( e->bei_parent ); + #ifdef BDB_HIER e->bei_parent->bei_ckids--; - if ( e->bei_parent->bei_dkids ) e->bei_parent->bei_dkids--; + if ( decr && e->bei_parent->bei_dkids ) e->bei_parent->bei_dkids--; #endif /* dn tree */ if ( avl_delete( &e->bei_parent->bei_kids, (caddr_t) e, bdb_rdn_cmp ) @@ -1084,14 +1107,15 @@ bdb_cache_delete_internal( return rc; } + cache->c_eiused--; + /* lru */ LRU_DELETE( cache, e ); - cache->c_cursize--; + if ( e->bei_e ) cache->c_cursize--; - /* - * flag entry to be freed later by a call to cache_return_entry() - */ - e->bei_state |= CACHE_ENTRY_DELETED; + /* free cache write lock */ + ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); + bdb_cache_entryinfo_unlock( e->bei_parent ); return( 0 ); } diff --git a/servers/slapd/back-bdb/ctxcsn.c b/servers/slapd/back-bdb/ctxcsn.c index 1127995de3..2aef9ce60f 100644 --- a/servers/slapd/back-bdb/ctxcsn.c +++ b/servers/slapd/back-bdb/ctxcsn.c @@ -107,13 +107,9 @@ bdb_csn_commit( &rs->sr_text, textbuf, textlen ); op->o_tmpfree( max_committed_csn.bv_val, op->o_tmpmemctx ); if ( ret != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_csn_commit: modify failed (%d)\n", rs->sr_err, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "bdb_csn_commit: modify failed (%d)\n", rs->sr_err, 0, 0 ); -#endif + if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs ); switch( ret ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -129,13 +125,23 @@ bdb_csn_commit( break; case DB_LOCK_DEADLOCK : case DB_LOCK_NOTGRANTED : + if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs ); goto rewind; default : + if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs ); rs->sr_err = ret; rs->sr_text = "context csn update failed"; return BDB_CSN_ABORT; } - bdb_cache_modify( *ctxcsn_e, dummy.e_attrs, bdb->bi_dbenv, locker, &ctxcsn_lock ); + ret = bdb_cache_modify( *ctxcsn_e, dummy.e_attrs, bdb->bi_dbenv, locker, &ctxcsn_lock ); + if ( ret != LDAP_SUCCESS ) { + if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs ); + switch( ret ) { + case DB_LOCK_DEADLOCK: + case DB_LOCK_NOTGRANTED: + goto rewind; + } + } } break; case DB_NOTFOUND: @@ -151,13 +157,9 @@ bdb_csn_commit( /* This serializes add. But this case is very rare : only once. */ rs->sr_err = bdb_next_id( op->o_bd, tid, &ctxcsn_id ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_add: next_id failed (%d)\n", rs->sr_err, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_add: next_id failed (%d)\n", rs->sr_err, 0, 0 ); -#endif + "bdb_csn_commit: next_id failed (%d)\n", + rs->sr_err, 0, 0 ); rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; return BDB_CSN_ABORT; @@ -216,13 +218,8 @@ bdb_csn_commit( break; case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: -#ifdef NEW_LOGGING - LDAP_LOG( OPERATION, ERR, - "bdb_csn_commit : bdb_dn2entry retry\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "bdb_csn_commit : bdb_dn2entry retry\n", 0, 0, 0 ); -#endif goto rewind; case LDAP_BUSY: rs->sr_err = rc; diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index c433e1dce7..89b077dcb9 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -36,6 +36,7 @@ bdb_delete( Operation *op, SlapReply *rs ) AttributeDescription *entry = slap_schema.si_ad_entry; DB_TXN *ltid = NULL, *lt2; struct bdb_op_info opinfo; + ID eid; u_int32_t locker = 0; DB_LOCK lock, plock; @@ -55,15 +56,15 @@ bdb_delete( Operation *op, SlapReply *rs ) int parent_is_glue = 0; int parent_is_leaf = 0; + struct berval ctxcsn_ndn = BER_BVNULL; + ctrls[num_ctrls] = 0; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ARGS, "==> bdb_delete: %s\n", - op->o_req_dn.bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ARGS, "==> bdb_delete: %s\n", + Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(bdb_delete) ": %s\n", op->o_req_dn.bv_val, 0, 0 ); -#endif + + build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], + (struct berval *)&slap_ldapsync_cn_bv, op->o_tmpmemctx ); if( 0 ) { retry: /* transaction retry */ @@ -75,13 +76,9 @@ retry: /* transaction retry */ bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, p); p = NULL; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==> bdb_delete: retrying...\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "==> bdb_delete: retrying...\n", + Debug( LDAP_DEBUG_TRACE, + "==> " LDAP_XSTRING(bdb_delete) ": retrying...\n", 0, 0, 0 ); -#endif rs->sr_err = TXN_ABORT( ltid ); ltid = NULL; op->o_private = NULL; @@ -102,15 +99,9 @@ retry: /* transaction retry */ bdb->bi_db_opflags ); rs->sr_text = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "==> bdb_delete: txn_begin failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_delete: txn_begin failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif + LDAP_XSTRING(bdb_delete) ": txn_begin failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -160,14 +151,9 @@ retry: /* transaction retry */ if ( e == NULL || ( !manageDSAit && is_entry_glue( e ))) { BerVarray deref = NULL; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ARGS, - "<=- bdb_delete: no such object %s\n", op->o_req_dn.bv_val, 0, 0); -#else Debug( LDAP_DEBUG_ARGS, - "<=- bdb_delete: no such object %s\n", + "<=- " LDAP_XSTRING(bdb_delete) ": no such object %s\n", op->o_req_dn.bv_val, 0, 0); -#endif if ( matched != NULL ) { rs->sr_matched = ch_strdup( matched->e_dn ); @@ -226,14 +212,9 @@ retry: /* transaction retry */ if ( pdn.bv_len != 0 ) { if( p == NULL || !bvmatch( &pdn, &p->e_nname )) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_delete: parent does not exist\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_delete: parent does not exist\n", - 0, 0, 0); -#endif + "<=- " LDAP_XSTRING(bdb_delete) ": parent " + "does not exist\n", 0, 0, 0 ); rs->sr_err = LDAP_OTHER; rs->sr_text = "could not locate parent of entry"; goto return_results; @@ -250,14 +231,9 @@ retry: /* transaction retry */ goto retry; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_delete: no write access to parent\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_delete: no write access to parent\n", - 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_delete) ": no write " + "access to parent\n", 0, 0, 0 ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; rs->sr_text = "no write access to parent"; goto return_results; @@ -283,28 +259,19 @@ retry: /* transaction retry */ goto retry; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_delete: no access to parent\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_delete: no access " - "to parent\n", 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_delete) + ": no access to parent\n", + 0, 0, 0 ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; rs->sr_text = "no write access to parent"; goto return_results; } } else { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_delete: no parent and not root\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_delete: no parent " - "and not root\n", 0, 0, 0); -#endif + "<=- " LDAP_XSTRING(bdb_delete) + ": no parent and not root\n", 0, 0, 0 ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; goto return_results; } @@ -328,14 +295,9 @@ retry: /* transaction retry */ goto retry; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_delete: no write access to entry\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_delete: no write access to entry\n", - 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_delete) ": no write access " + "to entry\n", 0, 0, 0 ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; rs->sr_text = "no write access to entry"; goto return_results; @@ -345,13 +307,9 @@ retry: /* transaction retry */ /* entry is a referral, don't allow delete */ rs->sr_ref = get_entry_referrals( op, e ); -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_delete: entry is referral\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_delete: entry is referral\n", 0, 0, 0 ); -#endif + LDAP_XSTRING(bdb_delete) ": entry is referral\n", + 0, 0, 0 ); rs->sr_err = LDAP_REFERRAL; rs->sr_matched = e->e_name.bv_val; @@ -374,13 +332,9 @@ retry: /* transaction retry */ if( slap_read_controls( op, rs, e, &slap_pre_read_bv, preread_ctrl ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_delete: pre-read failed!\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_delete: pre-read failed!\n", 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_delete) ": pre-read " + "failed!\n", 0, 0, 0 ); goto return_results; } } @@ -390,14 +344,9 @@ retry: /* transaction retry */ bdb->bi_db_opflags ); rs->sr_text = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_delete: txn_begin(2) failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_delete: txn_begin(2) failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif + LDAP_XSTRING(bdb_delete) ": txn_begin(2) failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -411,27 +360,18 @@ retry: /* transaction retry */ case DB_LOCK_NOTGRANTED: goto retry; case 0: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_delete: non-leaf %s\n", op->o_req_dn.bv_val, 0, 0 ); -#else Debug(LDAP_DEBUG_ARGS, - "<=- bdb_delete: non-leaf %s\n", + "<=- " LDAP_XSTRING(bdb_delete) + ": non-leaf %s\n", op->o_req_dn.bv_val, 0, 0); -#endif rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF; rs->sr_text = "subtree delete not supported"; break; default: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_delete: has_children failed %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_ARGS, - "<=- bdb_delete: has_children failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_delete) + ": has_children failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; } @@ -441,15 +381,9 @@ retry: /* transaction retry */ /* delete from dn2id */ rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_delete: dn2id failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_TRACE, - "<=- bdb_delete: dn2id failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_delete) ": dn2id failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -463,15 +397,9 @@ retry: /* transaction retry */ /* delete from id2entry */ rs->sr_err = bdb_id2entry_delete( op->o_bd, lt2, e ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_delete: id2entry failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_TRACE, - "<=- bdb_delete: id2entry failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_delete) ": id2entry failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -485,15 +413,9 @@ retry: /* transaction retry */ /* delete indices for old attributes */ rs->sr_err = bdb_index_entry_del( op, lt2, e ); if ( rs->sr_err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_delete: index failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_delete: index failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_delete) ": index failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -515,15 +437,10 @@ retry: /* transaction retry */ case 0: break; default: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_delete: has_children failed %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_ARGS, - "<=- bdb_delete: has_children failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_delete) + ": has_children failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -540,6 +457,8 @@ retry: /* transaction retry */ goto return_results; } + eid = e->e_id; + #if 0 /* Do we want to reclaim deleted IDs? */ ldap_pvt_thread_mutex_lock( &bdb->bi_lastid_mutex ); if ( e->e_id == bdb->bi_lastid ) { @@ -548,7 +467,9 @@ retry: /* transaction retry */ ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex ); #endif - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { + if ( !dn_match( &ctxcsn_ndn, &op->o_req_ndn ) && + !be_issuffix( op->o_bd, &op->o_req_ndn ) && + LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker ); switch ( rc ) { @@ -600,15 +521,11 @@ retry: /* transaction retry */ LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) { rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_DELETE ); if ( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_delete: persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_delete: persistent search failed (%d,%d)\n", + LDAP_XSTRING(bdb_delete) + ": persistent search failed " + "(%d,%d)\n", rc, rs->sr_err, 0 ); -#endif } } ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); @@ -620,34 +537,20 @@ retry: /* transaction retry */ op->o_private = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_delete: txn_%s failed: %s (%d)\n", - op->o_noop ? "abort (no-op)" : "commit", - db_strerror(rs->sr_err), rs->sr_err ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_delete: txn_%s failed: %s (%d)\n", + LDAP_XSTRING(bdb_delete) ": txn_%s failed: %s (%d)\n", op->o_noop ? "abort (no-op)" : "commit", db_strerror(rs->sr_err), rs->sr_err ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "commit failed"; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_delete: deleted%s id=%08lx db=\"%s\"\n", - op->o_noop ? " (no-op)" : "", - e->e_id, e->e_dn ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_delete: deleted%s id=%08lx dn=\"%s\"\n", + LDAP_XSTRING(bdb_delete) ": deleted%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", - e->e_id, e->e_dn ); -#endif + eid, op->o_req_dn.bv_val ); rs->sr_err = LDAP_SUCCESS; rs->sr_text = NULL; if( num_ctrls ) rs->sr_ctrls = ctrls; @@ -673,7 +576,7 @@ done: if( e != NULL ) { if ( rs->sr_err == LDAP_SUCCESS ) { /* Free the EntryInfo and the Entry */ - bdb_cache_delete_cleanup( &bdb->bi_cache, e ); + bdb_cache_delete_cleanup( &bdb->bi_cache, BEI(e) ); } else { bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e); } @@ -684,9 +587,11 @@ done: op->o_private = NULL; } + slap_sl_free( ctxcsn_ndn.bv_val, op->o_tmpmemctx ); + if( preread_ctrl != NULL ) { - slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx ); - slap_sl_free( *preread_ctrl, &op->o_tmpmemctx ); + slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx ); + slap_sl_free( *preread_ctrl, op->o_tmpmemctx ); } return rs->sr_err; } diff --git a/servers/slapd/back-bdb/error.c b/servers/slapd/back-bdb/error.c index 4b58c834c2..19771dd382 100644 --- a/servers/slapd/back-bdb/error.c +++ b/servers/slapd/back-bdb/error.c @@ -22,17 +22,17 @@ #include "slap.h" #include "back-bdb.h" +#if DB_VERSION_FULL < 0x04030000 void bdb_errcall( const char *pfx, char * msg ) +#else +void bdb_errcall( const DB_ENV *env, const char *pfx, char * msg ) +#endif { #ifdef HAVE_EBCDIC if ( msg[0] > 0x7f ) __etoa( msg ); #endif -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, INFO, "bdb(%s): %s\n", pfx, msg, 0 ); -#else Debug( LDAP_DEBUG_ANY, "bdb(%s): %s\n", pfx, msg, 0 ); -#endif } #ifdef HAVE_EBCDIC diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index 2dbb326e32..0193009223 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -60,14 +60,7 @@ bdb_filter_candidates( ID *stack ) { int rc = 0; -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ENTRY, "=> bdb_filter_candidates\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "=> bdb_filter_candidates\n", 0, 0, 0 ); -#endif -#if 0 - char *subtree="SUBTREE"; -#endif switch ( f->f_choice ) { case SLAPD_FILTER_COMPUTED: @@ -89,159 +82,72 @@ bdb_filter_candidates( break; } break; -#if 0 /* Not used any more, search calls bdb_dn2idl directly */ - case SLAPD_FILTER_DN_ONE: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN ONE\n", - 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 ); -#endif - rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_ONE_PREFIX, ids, - stack, op->o_tmpmemctx ); - if( rc == DB_NOTFOUND ) { - BDB_IDL_ZERO( ids ); - rc = 0; - } - break; - - case SLAPD_FILTER_DN_CHILDREN: - subtree="CHILDREN"; - /* Fall Thru */ - case SLAPD_FILTER_DN_SUBTREE: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN %s\n", - subtree, 0, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, "\tDN %s\n", - subtree, 0, 0 ); -#endif - rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids, - stack, op->o_tmpmemctx ); - break; -#endif case LDAP_FILTER_PRESENT: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tPRESENT\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 ); -#endif rc = presence_candidates( op, f->f_desc, ids ); break; case LDAP_FILTER_EQUALITY: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tEQUALITY\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 ); -#endif rc = equality_candidates( op, f->f_ava, ids, tmp ); break; case LDAP_FILTER_APPROX: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAPPROX\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 ); -#endif rc = approx_candidates( op, f->f_ava, ids, tmp ); break; case LDAP_FILTER_SUBSTRINGS: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tSUBSTRINGS\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 ); -#endif rc = substring_candidates( op, f->f_sub, ids, tmp ); break; case LDAP_FILTER_GE: /* no GE index, use pres */ -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tGE\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 ); -#endif rc = presence_candidates( op, f->f_ava->aa_desc, ids ); break; case LDAP_FILTER_LE: /* no LE index, use pres */ -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tLE\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 ); -#endif rc = presence_candidates( op, f->f_ava->aa_desc, ids ); break; case LDAP_FILTER_NOT: /* no indexing to support NOT filters */ -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tNOT\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 ); -#endif { struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; BDB_IDL_ALL( bdb, ids ); } break; case LDAP_FILTER_AND: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAND\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 ); -#endif rc = list_candidates( op, f->f_and, LDAP_FILTER_AND, ids, tmp, stack ); break; case LDAP_FILTER_OR: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tOR\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 ); -#endif rc = list_candidates( op, f->f_or, LDAP_FILTER_OR, ids, tmp, stack ); break; default: -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tUNKNOWN\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN %lu\n", (unsigned long) f->f_choice, 0, 0 ); -#endif /* Must not return NULL, otherwise extended filters break */ { struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; BDB_IDL_ALL( bdb, ids ); } } -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_filter_candidates: id=%ld first=%ld last=%ld\n", - (long)ids[0], (long)BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids )); -#else Debug( LDAP_DEBUG_FILTER, "<= bdb_filter_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) ); -#endif return rc; } @@ -259,11 +165,7 @@ list_candidates( int rc = 0; Filter *f; -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "=> bdb_list_candidates: 0x%x\n", ftype, 0 , 0 ); -#else Debug( LDAP_DEBUG_FILTER, "=> bdb_list_candidates 0x%x\n", ftype, 0, 0 ); -#endif for ( f = flist; f != NULL; f = f->f_next ) { /* ignore precomputed scopes */ if ( f->f_choice == SLAPD_FILTER_COMPUTED && @@ -301,27 +203,16 @@ list_candidates( } if( rc == LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_list_candidates: id=%ld first=%ld last=%ld\n", - (long) ids[0], (long) BDB_IDL_FIRST( ids ), - (long) BDB_IDL_LAST( ids ) ); -#else Debug( LDAP_DEBUG_FILTER, "<= bdb_list_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); -#endif } else { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ARGS, "<= bdb_list_candidates: rc=%d\n", rc, 0, 0 ); -#else Debug( LDAP_DEBUG_FILTER, "<= bdb_list_candidates: undefined rc=%d\n", rc, 0, 0 ); -#endif } return rc; @@ -339,13 +230,8 @@ presence_candidates( slap_mask_t mask; struct berval prefix = {0, NULL}; -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ENTRY, "=> bdb_presence_candidates (%s)\n", - desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "=> bdb_presence_candidates (%s)\n", desc->ad_cname.bv_val, 0, 0 ); -#endif BDB_IDL_ALL( bdb, ids ); @@ -357,44 +243,25 @@ presence_candidates( &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_presence_candidates: (%s) index_param " - "returned=%d\n", - desc->ad_cname.bv_val, rc, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: (%s) index_param " "returned=%d\n", desc->ad_cname.bv_val, rc, 0 ); -#endif return 0; } if( db == NULL ) { /* not indexed */ -#ifdef NEW_LOGGING - LDAP_LOG(INDEX, RESULTS, - "<= bdb_presence_candidates: (%s) not indexed\n", - desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: (%s) not indexed\n", desc->ad_cname.bv_val, 0, 0 ); -#endif return 0; } if( prefix.bv_val == NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG(INDEX, RESULTS, - "<= bdb_presence_candidates: (%s) no prefix\n", - desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: (%s) no prefix\n", desc->ad_cname.bv_val, 0, 0 ); -#endif return -1; } @@ -404,31 +271,18 @@ presence_candidates( BDB_IDL_ZERO( ids ); rc = 0; } else if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_presence_candidates: (%s) " - "key read failed (%d)\n", - desc->ad_cname.bv_val, rc, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_presense_candidates: (%s) " "key read failed (%d)\n", desc->ad_cname.bv_val, rc, 0 ); -#endif goto done; } -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_presence_candidates: id=%ld first=%ld last=%ld\n", - (long)ids[0], (long)BDB_IDL_FIRST( ids ), (long)BDB_IDL_LAST( ids ) ); -#else Debug(LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); -#endif done: return rc; @@ -450,13 +304,8 @@ equality_candidates( struct berval *keys = NULL; MatchingRule *mr; -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ENTRY, "=> bdb_equality_candidates (%s)\n", - ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "=> bdb_equality_candidates (%s)\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#endif BDB_IDL_ALL( bdb, ids ); @@ -464,30 +313,17 @@ equality_candidates( &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_equality_candidates: (%s) " - "index_param failed (%d)\n", - ava->aa_desc->ad_cname.bv_val, rc, 0); -#else Debug( LDAP_DEBUG_ANY, "<= bdb_equality_candidates: (%s) " "index_param failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); -#endif return 0; } if ( db == NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG(INDEX, RESULTS, - "<= bdb_equality_candidates: (%s) not indexed\n", - ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "<= bdb_equality_candidates: (%s) not indexed\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#endif return 0; } @@ -510,30 +346,17 @@ equality_candidates( &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_equality_candidates: (%s, %s) " - "MR filter failed (%d)\n", - prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: (%s, %s) " "MR filter failed (%d)\n", prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc ); -#endif return 0; } if( keys == NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_equality_candidates: (%s) no keys\n", - ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: (%s) no keys\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#endif return 0; } @@ -545,30 +368,17 @@ equality_candidates( rc = 0; break; } else if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_equality_candidates: (%s) " - "key read failed (%d)\n", - ava->aa_desc->ad_cname.bv_val, rc, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: (%s) " "key read failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); -#endif break; } if( BDB_IDL_IS_ZERO( tmp ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_equality_candidates: (%s) NULL\n", - ava->aa_desc->ad_cname.bv_val, 0, 0); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: (%s) NULL\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#endif BDB_IDL_ZERO( ids ); break; } @@ -585,18 +395,11 @@ equality_candidates( ber_bvarray_free_x( keys, op->o_tmpmemctx ); -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_equality_candidates: id=%ld first=%ld last=%ld\n", - (long) ids[0], (long) BDB_IDL_FIRST( ids ), - (long) BDB_IDL_LAST( ids ) ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: id=%ld, first=%ld, last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); -#endif return( rc ); } @@ -617,13 +420,8 @@ approx_candidates( struct berval *keys = NULL; MatchingRule *mr; -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ENTRY, "=> bdb_approx_candidates (%s)\n", - ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "=> bdb_approx_candidates (%s)\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#endif BDB_IDL_ALL( bdb, ids ); @@ -631,30 +429,17 @@ approx_candidates( &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_approx_candidates: (%s) " - "index_param failed (%d)\n", - ava->aa_desc->ad_cname.bv_val, rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, "<= bdb_approx_candidates: (%s) " "index_param failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); -#endif return 0; } if ( db == NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG(INDEX, RESULTS, - "<= bdb_approx_candidates: (%s) not indexed\n", - ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "<= bdb_approx_candidates: (%s) not indexed\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#endif return 0; } @@ -682,30 +467,17 @@ approx_candidates( &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_approx_candidates: (%s, %s) " - "MR filter failed (%d)\n", - prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s, %s) " "MR filter failed (%d)\n", prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc ); -#endif return 0; } if( keys == NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_approx_candidates: (%s) no keys (%s)\n", - prefix.bv_val, ava->aa_desc->ad_cname.bv_val, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s) no keys (%s)\n", prefix.bv_val, ava->aa_desc->ad_cname.bv_val, 0 ); -#endif return 0; } @@ -717,30 +489,17 @@ approx_candidates( rc = 0; break; } else if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_approx_candidates: (%s) " - "key read failed (%d)\n", - ava->aa_desc->ad_cname.bv_val, rc, 0); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s) " "key read failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); -#endif break; } if( BDB_IDL_IS_ZERO( tmp ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_approx_candidates: (%s) NULL\n", - ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s) NULL\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); -#endif BDB_IDL_ZERO( ids ); break; } @@ -757,17 +516,10 @@ approx_candidates( ber_bvarray_free_x( keys, op->o_tmpmemctx ); -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_approx_candidates: id=%ld first=%ld last=%ld\n", - (long) ids[0], (long) BDB_IDL_FIRST( ids ), - (long) BDB_IDL_LAST( ids ) ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates %ld, first=%ld, last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); -#endif return( rc ); } @@ -787,13 +539,8 @@ substring_candidates( struct berval *keys = NULL; MatchingRule *mr; -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ENTRY, "=> bdb_substring_candidates (%s)\n", - sub->sa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "=> bdb_substring_candidates (%s)\n", sub->sa_desc->ad_cname.bv_val, 0, 0 ); -#endif BDB_IDL_ALL( bdb, ids ); @@ -801,30 +548,17 @@ substring_candidates( &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_substring_candidates: (%s) " - "index_param failed (%d)\n", - sub->sa_desc->ad_cname.bv_val, rc, 0); -#else Debug( LDAP_DEBUG_ANY, "<= bdb_substring_candidates: (%s) " "index_param failed (%d)\n", sub->sa_desc->ad_cname.bv_val, rc, 0 ); -#endif return 0; } if ( db == NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_substring_candidates: (%s) not indexed\n", - sub->sa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "<= bdb_substring_candidates: (%s) not indexed\n", sub->sa_desc->ad_cname.bv_val, 0, 0 ); -#endif return 0; } @@ -848,30 +582,17 @@ substring_candidates( &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_substring_candidates: (%s) " - "MR filter failed (%d)\n", - sub->sa_desc->ad_cname.bv_val, rc, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (%s) " "MR filter failed (%d)\n", sub->sa_desc->ad_cname.bv_val, rc, 0 ); -#endif return 0; } if( keys == NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_substring_candidates: (0x%04lx) no keys (%s)\n", - mask, sub->sa_desc->ad_cname.bv_val, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (0x%04lx) no keys (%s)\n", mask, sub->sa_desc->ad_cname.bv_val, 0 ); -#endif return 0; } @@ -883,30 +604,17 @@ substring_candidates( rc = 0; break; } else if( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_substring_candidates: (%s) " - "key read failed (%d)\n", - sub->sa_desc->ad_cname.bv_val, rc, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (%s) " "key read failed (%d)\n", sub->sa_desc->ad_cname.bv_val, rc, 0 ); -#endif break; } if( BDB_IDL_IS_ZERO( tmp ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_substring_candidates: (%s) NULL\n", - sub->sa_desc->ad_cname.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (%s) NULL\n", sub->sa_desc->ad_cname.bv_val, 0, 0 ); -#endif BDB_IDL_ZERO( ids ); break; } @@ -923,17 +631,10 @@ substring_candidates( ber_bvarray_free_x( keys, op->o_tmpmemctx ); -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, RESULTS, - "<= bdb_substring_candidates: id=%ld first=%ld last=%ld\n", - (long) ids[0], (long) BDB_IDL_FIRST( ids ), - (long) BDB_IDL_LAST( ids ) ); -#else Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: %ld, first=%ld, last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); -#endif return( rc ); } diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index 05501b0e42..0efa3d82f6 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -332,7 +332,6 @@ dn2entry_retry: ndn->bv_val, 0, 0 ); #endif -#ifdef BDB_ALIASES /* find attribute values */ if( is_entry_alias( e ) ) { #ifdef NEW_LOGGING @@ -345,7 +344,6 @@ dn2entry_retry: rc = LDAP_ALIAS_PROBLEM; goto return_results; } -#endif if( is_entry_referral( e ) ) { #ifdef NEW_LOGGING diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 9d33f95371..9250f94f08 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -67,13 +67,9 @@ bdb_db_init( BackendDB *be ) { struct bdb_info *bdb; -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ENTRY, "bdb_db_init", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "bdb_db_init: Initializing %s database\n", - be->bd_info->bi_type, 0, 0 ); -#endif + LDAP_XSTRING(bdb_db_init) ": Initializing " + BDB_UCTYPE " database\n", 0, 0, 0 ); /* allocate backend-database-specific stuff */ bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) ); @@ -138,24 +134,14 @@ bdb_db_open( BackendDB *be ) char path[MAXPATHLEN]; #endif -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ARGS, - "bdb_db_open: %s\n", be->be_suffix[0].bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ARGS, "bdb_db_open: %s\n", be->be_suffix[0].bv_val, 0, 0 ); -#endif #ifndef BDB_MULTIPLE_SUFFIXES if ( be->be_suffix[1].bv_val ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: only one suffix allowed\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: only one suffix allowed\n", 0, 0, 0 ); -#endif return -1; } #endif @@ -163,15 +149,9 @@ bdb_db_open( BackendDB *be ) rc = db_env_create( &bdb->bi_dbenv, 0 ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: db_env_create failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: db_env_create failed: %s (%d)\n", db_strerror(rc), rc, 0 ); -#endif return rc; } @@ -231,15 +211,9 @@ bdb_db_open( BackendDB *be ) #endif rc = bdb->bi_dbenv->set_tmp_dir( bdb->bi_dbenv, dir ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n", - dir, db_strerror(rc), rc ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n", dir, db_strerror(rc), rc ); -#endif return rc; } @@ -249,15 +223,9 @@ bdb_db_open( BackendDB *be ) #endif rc = bdb->bi_dbenv->set_lg_dir( bdb->bi_dbenv, dir ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n", - dir, db_strerror(rc), rc ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n", dir, db_strerror(rc), rc ); -#endif return rc; } @@ -267,28 +235,28 @@ bdb_db_open( BackendDB *be ) #endif rc = bdb->bi_dbenv->set_data_dir( bdb->bi_dbenv, dir ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n", - dir, db_strerror(rc), rc ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n", dir, db_strerror(rc), rc ); -#endif return rc; } } #endif -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, - "bdb_db_open: dbenv_open %s\n", bdb->bi_dbenv_home, 0, 0 ); -#else + if( bdb->bi_dbenv_xflags != 0 ) { + rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv, + bdb->bi_dbenv_xflags, 1); + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "bdb_db_open: dbenv_set_flags failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); + return rc; + } + } + Debug( LDAP_DEBUG_TRACE, "bdb_db_open: dbenv_open(%s)\n", bdb->bi_dbenv_home, 0, 0); -#endif #ifdef HAVE_EBCDIC strcpy( path, bdb->bi_dbenv_home ); @@ -304,35 +272,12 @@ bdb_db_open( BackendDB *be ) bdb->bi_dbenv_mode ); #endif if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: dbenv_open failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: dbenv_open failed: %s (%d)\n", db_strerror(rc), rc, 0 ); -#endif return rc; } - if( bdb->bi_dbenv_xflags != 0 ) { - rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv, - bdb->bi_dbenv_xflags, 1); - if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: dbenv_set_flags failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else - Debug( LDAP_DEBUG_ANY, - "bdb_db_open: dbenv_set_flags failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#endif - return rc; - } - } - flags = DB_THREAD | bdb->bi_db_opflags; bdb->bi_databases = (struct bdb_db_info **) ch_malloc( @@ -346,15 +291,9 @@ bdb_db_open( BackendDB *be ) rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: db_create(%s) failed: %s (%d)\n", - bdb->bi_dbenv_home, db_strerror(rc), rc ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: db_create(%s) failed: %s (%d)\n", bdb->bi_dbenv_home, db_strerror(rc), rc ); -#endif return rc; } @@ -413,15 +352,9 @@ bdb_db_open( BackendDB *be ) #endif if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: db_create(%s) failed: %s (%d)\n", - bdb->bi_dbenv_home, db_strerror(rc), rc ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: db_open(%s) failed: %s (%d)\n", bdb->bi_dbenv_home, db_strerror(rc), rc ); -#endif return rc; } @@ -436,15 +369,9 @@ bdb_db_open( BackendDB *be ) /* get nextid */ rc = bdb_last_id( be, NULL ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_open: last_id(%s) failed: %s (%d)\n", - bdb->bi_dbenv_home, db_strerror(rc), rc ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_open: last_id(%s) failed: %s (%d)\n", bdb->bi_dbenv_home, db_strerror(rc), rc ); -#endif return rc; } @@ -509,29 +436,17 @@ bdb_db_destroy( BackendDB *be ) /* force a checkpoint */ rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n", db_strerror(rc), rc, 0 ); -#endif } rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 ); bdb->bi_dbenv = NULL; if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_db_destroy: close failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, "bdb_db_destroy: close failed: %s (%d)\n", db_strerror(rc), rc, 0 ); -#endif return rc; } } @@ -658,21 +573,16 @@ bdb_initialize( }; /* initialize the underlying database system */ -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ENTRY, "bdb_db_initialize\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_initialize: initialize BDB backend\n", - 0, 0, 0 ); -#endif + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_back_initialize) ": initialize " + BDB_UCTYPE " backend\n", 0, 0, 0 ); bi->bi_flags |= SLAP_BFLAG_INCREMENT | #ifdef BDB_SUBENTRIES SLAP_BFLAG_SUBENTRIES | #endif -#ifdef BDB_ALIASES SLAP_BFLAG_ALIASES | -#endif SLAP_BFLAG_REFERRALS; bi->bi_controls = controls; @@ -696,26 +606,15 @@ bdb_initialize( minor != DB_VERSION_MINOR || patch < DB_VERSION_PATCH ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, ERR, - "bdb_initialize: BDB library version mismatch:" - " expected " DB_VERSION_STRING "," - " got %s\n", version, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "bdb_initialize: BDB library version mismatch:" + LDAP_XSTRING(bdb_back_initialize) ": " + "BDB library version mismatch:" " expected " DB_VERSION_STRING "," " got %s\n", version, 0, 0 ); -#endif } -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, DETAIL1, - "bdb_db_initialize: %s\n", version, 0, 0 ); -#else - Debug( LDAP_DEBUG_ANY, "bdb_initialize: %s\n", - version, 0, 0 ); -#endif + Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_back_initialize) + ": %s\n", version, 0, 0 ); } db_env_set_func_free( ber_memfree ); diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index d45f1ba09c..3c402a8749 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -44,13 +44,8 @@ int bdb_modify_internal( Attribute *ap; int glue_attr_delete = 0; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ENTRY, "bdb_modify_internal: 0x%08lx: %s\n", - e->e_id, e->e_dn, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "bdb_modify_internal: 0x%08lx: %s\n", e->e_id, e->e_dn, 0); -#endif if ( !acl_check_modlist( op, e, modlist )) { return LDAP_INSUFFICIENT_ACCESS; @@ -97,21 +92,12 @@ int bdb_modify_internal( switch ( mod->sm_op ) { case LDAP_MOD_ADD: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, "bdb_modify_internal: add\n", 0,0,0); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: add\n", 0, 0, 0); -#endif err = modify_add_values( e, mod, get_permissiveModify(op), text, textbuf, textlen ); if( err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: %d %s\n", err, *text, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); -#endif } break; @@ -121,75 +107,40 @@ int bdb_modify_internal( break; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modify_internal: delete\n", 0, 0, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: delete\n", 0, 0, 0); -#endif err = modify_delete_values( e, mod, get_permissiveModify(op), text, textbuf, textlen ); assert( err != LDAP_TYPE_OR_VALUE_EXISTS ); if( err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: %d %s\n", err, *text, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); -#endif } break; case LDAP_MOD_REPLACE: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modify_internal: replace\n", 0, 0, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: replace\n", 0, 0, 0); -#endif err = modify_replace_values( e, mod, get_permissiveModify(op), text, textbuf, textlen ); if( err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: %d %s\n", err, *text, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); -#endif } break; case LDAP_MOD_INCREMENT: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modify_internal: increment\n", 0, 0, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: increment\n", 0, 0, 0); -#endif err = modify_increment_values( e, mod, get_permissiveModify(op), text, textbuf, textlen ); if( err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: %d %s\n", err, *text, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); -#endif } break; case SLAP_MOD_SOFTADD: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modify_internal: softadd\n",0,0,0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: softadd\n", 0, 0, 0); -#endif /* Avoid problems in index_add_mods() * We need to add index if necessary. */ @@ -205,33 +156,18 @@ int bdb_modify_internal( } if( err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: %d %s\n", err, *text, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); -#endif } break; default: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: invalid op %d\n", mod->sm_op, 0, 0 ); -#else Debug(LDAP_DEBUG_ANY, "bdb_modify_internal: invalid op %d\n", mod->sm_op, 0, 0); -#endif *text = "Invalid modify operation"; err = LDAP_OTHER; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: %d %s\n", err, *text, 0 ); -#else Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n", err, *text, 0); -#endif } if ( err != LDAP_SUCCESS ) { @@ -273,15 +209,9 @@ int bdb_modify_internal( e->e_attrs = save_attrs; if ( rc != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, "bdb_modify_internal: " - "entry failed schema check %s\n", - *text, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "entry failed schema check: %s\n", *text, 0, 0 ); -#endif } /* if NOOP then silently revert to saved attrs */ @@ -299,15 +229,9 @@ int bdb_modify_internal( if ( rc != LDAP_SUCCESS ) { attrs_free( e->e_attrs ); e->e_attrs = save_attrs; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: attribute index delete failure\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "Attribute index delete failure", 0, 0, 0 ); -#endif return rc; } ap->a_flags &= ~SLAP_ATTR_IXDEL; @@ -323,15 +247,9 @@ int bdb_modify_internal( if ( rc != LDAP_SUCCESS ) { attrs_free( e->e_attrs ); e->e_attrs = save_attrs; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify_internal: attribute index add failure\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "Attribute index add failure", 0, 0, 0 ); -#endif return rc; } ap->a_flags &= ~SLAP_ATTR_IXADD; @@ -372,13 +290,8 @@ bdb_modify( Operation *op, SlapReply *rs ) Entry *ctxcsn_e; int ctxcsn_added = 0; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ENTRY, "bdb_modify: %s\n", - op->o_req_dn.bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n", + Debug( LDAP_DEBUG_ARGS, LDAP_XSTRING(bdb_modify) ": %s\n", op->o_req_dn.bv_val, 0, 0 ); -#endif ctrls[num_ctrls] = NULL; @@ -392,12 +305,8 @@ retry: /* transaction retry */ bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e); e = NULL; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, "bdb_modify: retrying...\n", 0, 0, 0 ); -#else Debug(LDAP_DEBUG_TRACE, - "bdb_modify: retrying...\n", 0, 0, 0); -#endif + LDAP_XSTRING(bdb_modify) ": retrying...\n", 0, 0, 0); pm_list = LDAP_LIST_FIRST(&op->o_pm_list); while ( pm_list != NULL ) { @@ -425,14 +334,9 @@ retry: /* transaction retry */ bdb->bi_db_opflags ); rs->sr_text = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modify: txn_begin failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: txn_begin failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif + LDAP_XSTRING(bdb_modify) ": txn_begin failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -452,14 +356,9 @@ retry: /* transaction retry */ locker, &lock ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modify: dn2entry failed: (%d)\n", rs->sr_err, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: dn2entry failed (%d)\n", + LDAP_XSTRING(bdb_modify) ": dn2entry failed (%d)\n", rs->sr_err, 0, 0 ); -#endif switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -526,15 +425,9 @@ retry: /* transaction retry */ /* entry is a referral, don't allow modify */ rs->sr_ref = get_entry_referrals( op, e ); -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modify: entry is referral\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: entry is referral\n", + LDAP_XSTRING(bdb_modify) ": entry is referral\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_REFERRAL; rs->sr_matched = e->e_name.bv_val; @@ -558,15 +451,10 @@ retry: /* transaction retry */ LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) { rc = bdb_psearch(op, rs, ps_list, e, LDAP_PSEARCH_BY_PREMODIFY ); if ( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify: persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: persistent search failed (%d,%d)\n", + LDAP_XSTRING(bdb_modify) + ": persistent search failed (%d,%d)\n", rc, rs->sr_err, 0 ); -#endif } } ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); @@ -580,13 +468,9 @@ retry: /* transaction retry */ if ( slap_read_controls( op, rs, e, &slap_pre_read_bv, preread_ctrl ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_modify: pre-read failed!\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_modify: pre-read failed!\n", 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_modify) + ": pre-read failed!\n", 0, 0, 0 ); goto return_results; } } @@ -596,15 +480,10 @@ retry: /* transaction retry */ bdb->bi_db_opflags ); rs->sr_text = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify: txn_begin(2) failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: txn_begin(2) failed: %s (%d)\n", + LDAP_XSTRING(bdb_modify) ": txn_begin(2) failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -615,14 +494,9 @@ retry: /* transaction retry */ &dummy, &rs->sr_text, textbuf, textlen ); if( rs->sr_err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify: modify failed (%d)\n", rs->sr_err, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: modify failed (%d)\n", + LDAP_XSTRING(bdb_modify) ": modify failed (%d)\n", rs->sr_err, 0, 0 ); -#endif if ( (rs->sr_err == LDAP_INSUFFICIENT_ACCESS) && opinfo.boi_err ) { rs->sr_err = opinfo.boi_err; } @@ -639,14 +513,9 @@ retry: /* transaction retry */ /* change the entry itself */ rs->sr_err = bdb_id2entry_update( op->o_bd, lt2, &dummy ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify: id2entry update failed (%d)\n", rs->sr_err, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: id2entry update failed (%d)\n", - rs->sr_err, 0, 0 ); -#endif + LDAP_XSTRING(bdb_modify) ": id2entry update failed " + "(%d)\n", rs->sr_err, 0, 0 ); switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -681,13 +550,9 @@ retry: /* transaction retry */ if( slap_read_controls( op, rs, &dummy, &slap_post_read_bv, postread_ctrl ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_modify: post-read failed!\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_modify: post-read failed!\n", 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_modify) + ": post-read failed!\n", 0, 0, 0 ); goto return_results; } } @@ -721,15 +586,11 @@ retry: /* transaction retry */ LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) { rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY ); if ( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify: persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: persistent search failed (%d,%d)\n", + LDAP_XSTRING(bdb_modify) + ": persistent search failed " + "(%d,%d)\n", rc, rs->sr_err, 0 ); -#endif } } pm_list = LDAP_LIST_FIRST(&op->o_pm_list); @@ -737,15 +598,11 @@ retry: /* transaction retry */ rc = bdb_psearch(op, rs, pm_list->ps_op, e, LDAP_PSEARCH_BY_SCOPEOUT); if ( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify: persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: persistent search failed (%d,%d)\n", + LDAP_XSTRING(bdb_modify) + ": persistent search failed " + "(%d,%d)\n", rc, rs->sr_err, 0 ); -#endif } LDAP_LIST_REMOVE ( pm_list, ps_link ); pm_prev = pm_list; @@ -761,33 +618,20 @@ retry: /* transaction retry */ op->o_private = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modify: txn_%s failed %s (%d)\n", - op->o_noop ? "abort (no_op)" : "commit", - db_strerror(rs->sr_err), rs->sr_err ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: txn_%s failed: %s (%d)\n", + LDAP_XSTRING(bdb_modify) ": txn_%s failed: %s (%d)\n", op->o_noop ? "abort (no-op)" : "commit", db_strerror(rs->sr_err), rs->sr_err ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "commit failed"; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modify: updated%s id=%08lx dn=\"%s\"\n", - op->o_noop ? " (no_op)" : "", e->e_id, e->e_dn ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modify: updated%s id=%08lx dn=\"%s\"\n", + LDAP_XSTRING(bdb_modify) ": updated%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", - e->e_id, e->e_dn ); -#endif + dummy.e_id, op->o_req_dn.bv_val ); rs->sr_err = LDAP_SUCCESS; rs->sr_text = NULL; @@ -823,12 +667,12 @@ done: } if( preread_ctrl != NULL ) { - slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx ); - slap_sl_free( *preread_ctrl, &op->o_tmpmemctx ); + slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx ); + slap_sl_free( *preread_ctrl, op->o_tmpmemctx ); } if( postread_ctrl != NULL ) { - slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx ); - slap_sl_free( *postread_ctrl, &op->o_tmpmemctx ); + slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx ); + slap_sl_free( *postread_ctrl, op->o_tmpmemctx ); } return rs->sr_err; } diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index fd88485bd0..a424c24aa3 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -77,15 +77,9 @@ bdb_modrdn( Operation *op, SlapReply *rs ) ctrls[num_ctrls] = NULL; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ENTRY, "==>bdb_modrdn(%s,%s,%s)\n", + Debug( LDAP_DEBUG_TRACE, "==>" LDAP_XSTRING(bdb_modrdn) "(%s,%s,%s)\n", op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val, op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_val : "NULL" ); -#else - Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n", - op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val, - op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_val : "NULL" ); -#endif if( 0 ) { retry: /* transaction retry */ @@ -105,11 +99,8 @@ retry: /* transaction retry */ bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, np); np = NULL; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, "==>bdb_modrdn: retrying...\n", 0, 0, 0); -#else - Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 ); -#endif + Debug( LDAP_DEBUG_TRACE, "==>" LDAP_XSTRING(bdb_modrdn) + ": retrying...\n", 0, 0, 0 ); pm_list = LDAP_LIST_FIRST(&op->o_pm_list); while ( pm_list != NULL ) { LDAP_LIST_REMOVE ( pm_list, ps_link ); @@ -138,15 +129,9 @@ retry: /* transaction retry */ bdb->bi_db_opflags ); rs->sr_text = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "==>bdb_modrdn: txn_begin failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_delete: txn_begin failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif + LDAP_XSTRING(bdb_modrdn) ": txn_begin failed: " + "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -240,13 +225,8 @@ retry: /* transaction retry */ goto retry; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "==>bdb_modrdn: no access to entry\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "no access to entry\n", 0, 0, 0 ); -#endif rs->sr_text = "no write access to old entry"; rs->sr_err = LDAP_INSUFFICIENT_ACCESS; goto return_results; @@ -260,27 +240,18 @@ retry: /* transaction retry */ case DB_LOCK_NOTGRANTED: goto retry; case 0: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_modrdn: non-leaf %s\n", op->o_req_dn.bv_val, 0, 0 ); -#else Debug(LDAP_DEBUG_ARGS, - "<=- bdb_modrdn: non-leaf %s\n", + "<=- " LDAP_XSTRING(bdb_modrdn) + ": non-leaf %s\n", op->o_req_dn.bv_val, 0, 0); -#endif rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF; rs->sr_text = "subtree rename not supported"; break; default: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_modrdn: has_children failed %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_ARGS, - "<=- bdb_modrdn: has_children failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_modrdn) + ": has_children failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; } @@ -293,13 +264,8 @@ retry: /* transaction retry */ /* parent is a referral, don't allow add */ rs->sr_ref = get_entry_referrals( op, e ); -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: entry %s is referral \n", e->e_dn, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n", - e->e_dn, 0, 0 ); -#endif + Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modrdn) + ": entry %s is referral\n", e->e_dn, 0, 0 ); rs->sr_err = LDAP_REFERRAL, rs->sr_matched = e->e_name.bv_val; @@ -343,13 +309,8 @@ retry: /* transaction retry */ p = eip->bei_e; if( p == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "==>bdb_modrdn: parent does not exist\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent does not exist\n", - 0, 0, 0); -#endif + Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modrdn) + ": parent does not exist\n", 0, 0, 0); rs->sr_err = LDAP_OTHER; rs->sr_text = "old entry's parent does not exist"; goto return_results; @@ -367,25 +328,15 @@ retry: /* transaction retry */ } rs->sr_err = LDAP_INSUFFICIENT_ACCESS; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "==>bdb_modrdn: no access to parent\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, 0, 0 ); -#endif rs->sr_text = "no write access to old parent's children"; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: wr to children %s is OK\n", p_ndn.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: wr to children of entry %s OK\n", - p_ndn.bv_val, 0, 0 ); -#endif + LDAP_XSTRING(bdb_modrdn) ": wr to children " + "of entry %s OK\n", p_ndn.bv_val, 0, 0 ); if ( p_ndn.bv_val == slap_empty_bv.bv_val ) { p_dn = slap_empty_bv; @@ -393,14 +344,9 @@ retry: /* transaction retry */ dnParent( &e->e_name, &p_dn ); } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: parent dn=%s\n", p_dn.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: parent dn=%s\n", + LDAP_XSTRING(bdb_modrdn) ": parent dn=%s\n", p_dn.bv_val, 0, 0 ); -#endif } else { /* no parent, modrdn entry directly under root */ @@ -425,51 +371,32 @@ retry: /* transaction retry */ } rs->sr_err = LDAP_INSUFFICIENT_ACCESS; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "==>bdb_modrdn: no access to parent\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, 0, 0 ); -#endif rs->sr_text = "no write access to old parent"; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: wr to children of entry \"%s\" OK\n", - p_dn.bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: wr to children of entry \"\" OK\n", + LDAP_XSTRING(bdb_modrdn) + ": wr to children of entry \"\" OK\n", 0, 0, 0 ); -#endif p_dn.bv_val = ""; p_dn.bv_len = 0; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: parent dn=\"\" \n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: parent dn=\"\"\n", + LDAP_XSTRING(bdb_modrdn) + ": parent dn=\"\"\n", 0, 0, 0 ); -#endif } else { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "==>bdb_modrdn: no parent, not root &\"\" is not " - "suffix\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: no parent, not root " + LDAP_XSTRING(bdb_modrdn) + ": no parent, not root " "& \"\" is not suffix\n", 0, 0, 0); -#endif rs->sr_text = "no write access to old parent"; rs->sr_err = LDAP_INSUFFICIENT_ACCESS; goto return_results; @@ -480,27 +407,16 @@ retry: /* transaction retry */ new_parent_dn = &p_dn; /* New Parent unless newSuperior given */ if ( op->oq_modrdn.rs_newSup != NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: new parent \"%s\" requested...\n", - op->oq_modrdn.rs_newSup->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: new parent \"%s\" requested...\n", + LDAP_XSTRING(bdb_modrdn) + ": new parent \"%s\" requested...\n", op->oq_modrdn.rs_newSup->bv_val, 0, 0 ); -#endif /* newSuperior == oldParent? */ if( dn_match( &p_ndn, op->oq_modrdn.rs_nnewSup ) ) { -#ifdef NEW_LOGGING - LDAP_LOG( BACK_BDB, INFO, "bdb_back_modrdn: " - "new parent \"%s\" same as the old parent \"%s\"\n", - op->oq_modrdn.rs_newSup->bv_val, p_dn.bv_val, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "bdb_back_modrdn: " "new parent \"%s\" same as the old parent \"%s\"\n", op->oq_modrdn.rs_newSup->bv_val, p_dn.bv_val, 0 ); -#endif op->oq_modrdn.rs_newSup = NULL; /* ignore newSuperior */ } } @@ -534,29 +450,19 @@ retry: /* transaction retry */ } if( np == NULL) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: newSup(ndn=%s) not here!\n", - np_ndn->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: newSup(ndn=%s) not here!\n", + LDAP_XSTRING(bdb_modrdn) + ": newSup(ndn=%s) not here!\n", np_ndn->bv_val, 0, 0); -#endif rs->sr_text = "new superior not found"; rs->sr_err = LDAP_OTHER; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: wr to new parent OK np=%p, id=%ld\n", - (void *) np, (long) np->e_id, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: wr to new parent OK np=%p, id=%ld\n", + LDAP_XSTRING(bdb_modrdn) + ": wr to new parent OK np=%p, id=%ld\n", (void *) np, (long) np->e_id, 0 ); -#endif /* check newSuperior for "children" acl */ rs->sr_err = access_allowed( op, np, children, @@ -569,44 +475,32 @@ retry: /* transaction retry */ goto retry; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: no wr to newSup children\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: no wr to newSup children\n", + LDAP_XSTRING(bdb_modrdn) + ": no wr to newSup children\n", 0, 0, 0 ); -#endif rs->sr_text = "no write access to new superior's children"; rs->sr_err = LDAP_INSUFFICIENT_ACCESS; goto return_results; } -#ifdef BDB_ALIASES if ( is_entry_alias( np ) ) { /* parent is an alias, don't allow add */ -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: entry is alias\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is alias\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_modrdn) + ": entry is alias\n", 0, 0, 0 ); -#endif rs->sr_text = "new superior is an alias"; rs->sr_err = LDAP_ALIAS_PROBLEM; goto return_results; } -#endif if ( is_entry_referral( np ) ) { /* parent is a referral, don't allow add */ -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "==>bdb_modrdn: entry is referral\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is referral\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_modrdn) + ": entry is referral\n", 0, 0, 0 ); -#endif rs->sr_text = "new superior is a referral"; rs->sr_err = LDAP_OTHER; goto return_results; @@ -639,63 +533,42 @@ retry: /* transaction retry */ } rs->sr_err = LDAP_INSUFFICIENT_ACCESS; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "==>bdb_modrdn: no access to superior\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, "no access to new superior\n", 0, 0, 0 ); -#endif rs->sr_text = "no write access to new superior's children"; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modrdn: wr to children entry \"\" OK\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: wr to children of entry \"\" OK\n", + LDAP_XSTRING(bdb_modrdn) + ": wr to children " + "of entry \"\" OK\n", 0, 0, 0 ); -#endif } else { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modrdn: new superior=\"\", not root & \"\" " - "is not suffix\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: new superior=\"\", not root " + LDAP_XSTRING(bdb_modrdn) + ": new superior=\"\", not root " "& \"\" is not suffix\n", - 0, 0, 0); -#endif + 0, 0, 0 ); rs->sr_text = "no write access to new superior's children"; rs->sr_err = LDAP_INSUFFICIENT_ACCESS; goto return_results; } } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modrdn: new superior=\"\"\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: new superior=\"\"\n", + LDAP_XSTRING(bdb_modrdn) + ": new superior=\"\"\n", 0, 0, 0 ); -#endif } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_modrdn: wr to new parent's children OK\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: wr to new parent's children OK\n", + LDAP_XSTRING(bdb_modrdn) + ": wr to new parent's children OK\n", 0, 0, 0 ); -#endif new_parent_dn = np_dn; } @@ -711,13 +584,8 @@ retry: /* transaction retry */ ber_dupbv( &new_ndn, &bv ); } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_modrdn: new ndn=%s\n", new_ndn.bv_val, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s\n", + Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modrdn) ": new ndn=%s\n", new_ndn.bv_val, 0, 0 ); -#endif /* Shortcut the search */ nei = neip ? neip : eip; @@ -744,47 +612,29 @@ retry: /* transaction retry */ if ( !new_rdn && ldap_bv2rdn_x( &op->oq_modrdn.rs_newrdn, &new_rdn, (char **)&rs->sr_text, LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modrdn: can't figure out " - "type(s)/values(s) of newrdn\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: can't figure out " + LDAP_XSTRING(bdb_modrdn) ": can't figure out " "type(s)/values(s) of newrdn\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_INVALID_DN_SYNTAX; rs->sr_text = "unknown type(s) used in RDN"; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", - new_rdn[ 0 ]->la_attr.bv_val, new_rdn[ 0 ]->la_value.bv_val, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", - new_rdn[ 0 ]->la_attr.bv_val, new_rdn[ 0 ]->la_value.bv_val, 0 ); -#endif + LDAP_XSTRING(bdb_modrdn) + ": new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", + new_rdn[ 0 ]->la_attr.bv_val, + new_rdn[ 0 ]->la_value.bv_val, 0 ); if ( op->oq_modrdn.rs_deleteoldrdn ) { if ( !old_rdn && ldap_bv2rdn_x( &op->o_req_dn, &old_rdn, (char **)&rs->sr_text, LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modrdn: can't figure out " - "type(s)/values(s) of old_rdn\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: can't figure out " + LDAP_XSTRING(bdb_modrdn) ": can't figure out " "the old_rdn type(s)/value(s)\n", 0, 0, 0 ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "cannot parse RDN from old DN"; goto return_results; @@ -807,13 +657,9 @@ retry: /* transaction retry */ if( slap_read_controls( op, rs, e, &slap_pre_read_bv, preread_ctrl ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_modrdn: post-read failed!\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_modrdn: post-read failed!\n", 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_modrdn) + ": post-read failed!\n", 0, 0, 0 ); goto return_results; } } @@ -822,15 +668,10 @@ retry: /* transaction retry */ rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, ltid, <2, bdb->bi_db_opflags ); rs->sr_text = NULL; if( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modrdn: txn_begin(2) failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: txn_begin(2) failed: %s (%d)\n", + LDAP_XSTRING(bdb_modrdn) + ": txn_begin(2) failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -839,15 +680,10 @@ retry: /* transaction retry */ /* delete old DN */ rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_modrdn: dn2id del failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_TRACE, - "<=- bdb_modrdn: dn2id del failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_modrdn) + ": dn2id del failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -867,15 +703,10 @@ retry: /* transaction retry */ /* add new DN */ rs->sr_err = bdb_dn2id_add( op, lt2, neip ? neip : eip, &dummy ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_modrdn: dn2id add failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_TRACE, - "<=- bdb_modrdn: dn2id add failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_modrdn) + ": dn2id add failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -893,15 +724,10 @@ retry: /* transaction retry */ LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) { rc = bdb_psearch( op, rs, ps_list, &dummy, LDAP_PSEARCH_BY_PREMODIFY ); if ( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modrdn: persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: persistent search failed (%d,%d)\n", + LDAP_XSTRING(bdb_modrdn) + ": persistent search failed (%d,%d)\n", rc, rs->sr_err, 0 ); -#endif } } ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); @@ -912,15 +738,10 @@ retry: /* transaction retry */ rs->sr_err = bdb_modify_internal( op, lt2, &mod[0], &dummy, &rs->sr_text, textbuf, textlen ); if( rs->sr_err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_modrdn: modify failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_TRACE, - "<=- bdb_modrdn: modify failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_modrdn) + ": modify failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif if ( ( rs->sr_err == LDAP_INSUFFICIENT_ACCESS ) && opinfo.boi_err ) { rs->sr_err = opinfo.boi_err; } @@ -936,15 +757,10 @@ retry: /* transaction retry */ /* id2entry index */ rs->sr_err = bdb_id2entry_update( op->o_bd, lt2, &dummy ); if ( rs->sr_err != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_modrdn: id2entry failed: %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_TRACE, - "<=- bdb_modrdn: id2entry failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_modrdn) + ": id2entry failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -966,15 +782,10 @@ retry: /* transaction retry */ case 0: break; default: -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "<=- bdb_modrdn: has_children failed %s (%d)\n", - db_strerror(rs->sr_err), rs->sr_err, 0 ); -#else Debug(LDAP_DEBUG_ARGS, - "<=- bdb_modrdn: has_children failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_modrdn) + ": has_children failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 ); -#endif rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; @@ -1010,13 +821,9 @@ retry: /* transaction retry */ if( slap_read_controls( op, rs, &dummy, &slap_post_read_bv, postread_ctrl ) ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "<=- bdb_modrdn: post-read failed!\n", 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "<=- bdb_modrdn: post-read failed!\n", 0, 0, 0 ); -#endif + "<=- " LDAP_XSTRING(bdb_modrdn) + ": post-read failed!\n", 0, 0, 0 ); goto return_results; } } @@ -1054,31 +861,23 @@ retry: /* transaction retry */ LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) { rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY ); if ( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modrdn: persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: persistent search failed (%d,%d)\n", + LDAP_XSTRING(bdb_modrdn) + ": persistent search failed " + "(%d,%d)\n", rc, rs->sr_err, 0 ); -#endif - } + } } pm_list = LDAP_LIST_FIRST(&op->o_pm_list); while ( pm_list != NULL ) { rc = bdb_psearch(op, rs, pm_list->ps_op, e, LDAP_PSEARCH_BY_SCOPEOUT); if ( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ERR, - "bdb_modrdn: persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: persistent search failed (%d,%d)\n", + LDAP_XSTRING(bdb_modrdn) + ": persistent search failed " + "(%d,%d)\n", rc, rs->sr_err, 0 ); -#endif } pm_prev = pm_list; LDAP_LIST_REMOVE ( pm_list, ps_link ); @@ -1099,29 +898,19 @@ retry: /* transaction retry */ op->o_private = NULL; if( rs->sr_err != LDAP_SUCCESS ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, "bdb_modrdn: %s : %s (%d)\n", - rs->sr_text, db_strerror(rs->sr_err), rs->sr_err ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_modrdn) ": %s : %s (%d)\n", rs->sr_text, db_strerror(rs->sr_err), rs->sr_err ); -#endif rs->sr_err = LDAP_OTHER; goto return_results; } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n", - op->o_noop ? " (no-op)" : "", - e->e_id, e->e_dn ); -#else Debug(LDAP_DEBUG_TRACE, - "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n", + LDAP_XSTRING(bdb_modrdn) + ": rdn modified%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", - e->e_id, e->e_dn ); -#endif + dummy.e_id, op->o_req_dn.bv_val ); rs->sr_text = NULL; if( num_ctrls ) rs->sr_ctrls = ctrls; @@ -1196,12 +985,12 @@ done: } if( preread_ctrl != NULL ) { - slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx ); - slap_sl_free( *preread_ctrl, &op->o_tmpmemctx ); + slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx ); + slap_sl_free( *preread_ctrl, op->o_tmpmemctx ); } if( postread_ctrl != NULL ) { - slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx ); - slap_sl_free( *postread_ctrl, &op->o_tmpmemctx ); + slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx ); + slap_sl_free( *postread_ctrl, op->o_tmpmemctx ); } return rs->sr_err; } diff --git a/servers/slapd/back-bdb/operational.c b/servers/slapd/back-bdb/operational.c index c239908eac..c31e829e71 100644 --- a/servers/slapd/back-bdb/operational.c +++ b/servers/slapd/back-bdb/operational.c @@ -76,7 +76,8 @@ retry: db_strerror(rc), rc, 0 ); #else Debug(LDAP_DEBUG_ARGS, - "<=- bdb_hasSubordinates: has_children failed: %s (%d)\n", + "<=- " LDAP_XSTRING(bdb_hasSubordinates) + ": has_children failed: %s (%d)\n", db_strerror(rc), rc, 0 ); #endif rc = LDAP_OTHER; diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index ccdb1aa505..f3418805da 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -20,8 +20,10 @@ LDAP_BEGIN_DECL #ifdef BDB_HIER #define BDB_SYMBOL(x) LDAP_CONCAT(hdb_,x) +#define BDB_UCTYPE "HDB" #else #define BDB_SYMBOL(x) LDAP_CONCAT(bdb_,x) +#define BDB_UCTYPE "BDB" #endif /* @@ -139,7 +141,11 @@ int bdb_fix_dn( Entry *e, int checkit ); */ #define bdb_errcall BDB_SYMBOL(errcall) +#if DB_VERSION_FULL < 0x04030000 void bdb_errcall( const char *pfx, char * msg ); +#else +void bdb_errcall( const DB_ENV *env, const char *pfx, char * msg ); +#endif #ifdef HAVE_EBCDIC #define ebcdic_dberror BDB_SYMBOL(ebcdic_dberror) @@ -482,7 +488,7 @@ int bdb_cache_delete( ); void bdb_cache_delete_cleanup( Cache *cache, - Entry *e + EntryInfo *ei ); void bdb_cache_release_all( Cache *cache ); void bdb_cache_delete_entry( diff --git a/servers/slapd/back-bdb/referral.c b/servers/slapd/back-bdb/referral.c index d69c35a7d9..a77201ba61 100644 --- a/servers/slapd/back-bdb/referral.c +++ b/servers/slapd/back-bdb/referral.c @@ -73,7 +73,8 @@ dn2entry_retry: db_strerror(rc), rc, 0 ); #else Debug( LDAP_DEBUG_TRACE, - "bdb_referrals: dn2entry failed: %s (%d)\n", + LDAP_XSTRING(bdb_referrals) + ": dn2entry failed: %s (%d)\n", db_strerror(rc), rc, 0 ); #endif send_ldap_error( op, rs, LDAP_OTHER, "internal error" ); @@ -91,7 +92,8 @@ dn2entry_retry: (long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val ); #else Debug( LDAP_DEBUG_TRACE, - "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", + LDAP_XSTRING(bdb_referrals) + ": op=%ld target=\"%s\" matched=\"%s\"\n", (long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val ); #endif @@ -144,7 +146,8 @@ dn2entry_retry: (long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val ); #else Debug( LDAP_DEBUG_TRACE, - "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", + LDAP_XSTRING(bdb_referrals) + ": op=%ld target=\"%s\" matched=\"%s\"\n", (long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val ); #endif diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 45750bc11b..abcd1f4c2e 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -483,11 +483,7 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop, void *memctx_null = NULL; -#ifdef NEW_LOGGING - LDAP_LOG( OPERATION, ENTRY, "bdb_search\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "=> bdb_search\n", 0, 0, 0); -#endif + Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_search) "\n", 0, 0, 0); attrs = sop->oq_search.rs_attrs; opinfo = (struct bdb_op_info *) op->o_private; @@ -712,13 +708,9 @@ dn2entry_retry: ber_bvarray_free( erefs ); } -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_search: entry is referral\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_search: entry is referral\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_search) ": entry is referral\n", 0, 0, 0 ); -#endif if (!rs->sr_ref) rs->sr_text = "bad_referral object"; rs->sr_err = LDAP_REFERRAL; @@ -818,13 +810,9 @@ dn2entry_retry: } if ( candidates[0] == 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_search: no candidates\n", 0, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_search: no candidates\n", + Debug( LDAP_DEBUG_TRACE, + LDAP_XSTRING(bdb_search) ": no candidates\n", 0, 0, 0 ); -#endif goto nochange; } @@ -867,15 +855,10 @@ dn2entry_retry: } if ( cursor == NOID ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_search: no paged results candidates\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_search: no paged results candidates\n", + LDAP_XSTRING(bdb_search) + ": no paged results candidates\n", 0, 0, 0 ); -#endif send_paged_response( sop, rs, &lastid, 0 ); rs->sr_err = LDAP_OTHER; @@ -1010,15 +993,10 @@ id2entry_retry: if ( e == NULL ) { if( !BDB_IDL_IS_RANGE(candidates) ) { /* only complain for non-range IDLs */ -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_search: candidate %ld not found\n", - (long) id, 0, 0); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_search: candidate %ld not found\n", + LDAP_XSTRING(bdb_search) + ": candidate %ld not found\n", (long) id, 0, 0 ); -#endif } goto loop_continue; @@ -1092,7 +1070,6 @@ id2entry_retry: } break; } -#ifdef BDB_ALIASES /* aliases were already dereferenced in candidate list */ if ( sop->ors_deref & LDAP_DEREF_SEARCHING ) { /* but if the search base is an alias, and we didn't @@ -1124,19 +1101,12 @@ id2entry_retry: } } } -#endif /* Not in scope, ignore it */ if ( !scopeok ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_search: %ld scope not okay\n", - (long) id, 0, 0); -#else Debug( LDAP_DEBUG_TRACE, "bdb_search: %ld scope not okay\n", (long) id, 0, 0 ); -#endif goto loop_continue; } @@ -1181,15 +1151,10 @@ id2entry_retry: if ( rs->sr_err == LDAP_COMPARE_TRUE ) { if ( rc_sync == LDAP_COMPARE_TRUE ) { if ( no_sync_state_change ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_search: error in context csn management\n", - 0, 0, 0 ); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_search: error in context csn management\n", + LDAP_XSTRING(bdb_search) ": " + "error in context csn management\n", 0, 0, 0 ); -#endif } entry_sync_state = LDAP_SYNC_ADD; @@ -1314,15 +1279,10 @@ id2entry_retry: psid_e, ps_link ); } else { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_search: invalid ps_type (%d) \n", - ps_type, 0, 0); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_search: invalid ps_type (%d) \n", + LDAP_XSTRING(bdb_search) + ": invalid ps_type (%d) \n", ps_type, 0, 0); -#endif } } else { @@ -1401,14 +1361,10 @@ id2entry_retry: } } else { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, RESULTS, - "bdb_search: %ld does not match filter\n", (long) id, 0, 0); -#else Debug( LDAP_DEBUG_TRACE, - "bdb_search: %ld does not match filter\n", + LDAP_XSTRING(bdb_search) + ": %ld does not match filter\n", (long) id, 0, 0 ); -#endif } loop_continue: @@ -1580,14 +1536,8 @@ static int base_candidate( Entry *e, ID *ids ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ENTRY, - "base_candidate: base: \"%s\" (0x%08lx)\n", - e->e_nname.bv_val, (long) e->e_id, 0); -#else Debug(LDAP_DEBUG_ARGS, "base_candidates: base: \"%s\" (0x%08lx)\n", e->e_nname.bv_val, (long) e->e_id, 0); -#endif ids[0] = 1; ids[1] = e->e_id; @@ -1685,15 +1635,9 @@ static int search_candidates( * (|[(objectClass=referral)(objectClass=alias)](user-filter)) */ -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ENTRY, - "search_candidates: base=\"%s\" (0x%08lx) scope=%d\n", - e->e_nname.bv_val, (long) e->e_id, op->oq_search.rs_scope); -#else Debug(LDAP_DEBUG_TRACE, "search_candidates: base=\"%s\" (0x%08lx) scope=%d\n", e->e_nname.bv_val, (long) e->e_id, op->oq_search.rs_scope ); -#endif xf.f_or = op->oq_search.rs_filter; xf.f_choice = LDAP_FILTER_OR; @@ -1732,7 +1676,7 @@ static int search_candidates( #ifdef BDB_SUBENTRIES if( get_subentries_visibility( op ) ) { - struct berval bv_subentry = BER_BVC( "SUBENTRY" ); + struct berval bv_subentry = BER_BVC( "subentry" ); sf.f_choice = LDAP_FILTER_EQUALITY; sf.f_ava = &aa_subentry; sf.f_av_desc = slap_schema.si_ad_objectClass; @@ -1765,28 +1709,16 @@ static int search_candidates( } if( rc ) { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_search_candidates: failed (rc=%d)\n", rc, 0, 0 ); -#else Debug(LDAP_DEBUG_TRACE, "bdb_search_candidates: failed (rc=%d)\n", rc, NULL, NULL ); -#endif } else { -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, DETAIL1, - "bdb_search_candidates: id=%ld first=%ld last=%ld\n", - (long) ids[0], (long) BDB_IDL_FIRST(ids), - (long) BDB_IDL_LAST(ids)); -#else Debug(LDAP_DEBUG_TRACE, "bdb_search_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); -#endif } return rc; @@ -1805,15 +1737,9 @@ send_paged_response( PagedResultsCookie respcookie; struct berval cookie; -#ifdef NEW_LOGGING - LDAP_LOG ( OPERATION, ENTRY, - "send_paged_response: lastid=0x%08lx nentries=%d\n", - lastid ? *lastid : 0, rs->sr_nentries, NULL ); -#else Debug(LDAP_DEBUG_ARGS, "send_paged_response: lastid=0x%08lx nentries=%d\n", lastid ? *lastid : 0, rs->sr_nentries, NULL ); -#endif BER_BVZERO( &ctrl.ldctl_value ); ctrls[0] = &ctrl; diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 6484e4db9e..94f6838e32 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -138,13 +138,9 @@ ID bdb_tool_dn2id_get( rc = db->get( db, NULL, &key, &data, bdb->bi_db_opflags ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( INDEX, ERR, "bdb_tool_dn2id_get: get failed %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "bdb_tool_dn2id_get: get failed: %s (%d)\n", + Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_tool_dn2id_get) + ": get failed: %s (%d)\n", db_strerror( rc ), rc, 0 ); -#endif id = NOID; } @@ -232,13 +228,8 @@ static int bdb_tool_next_id( snprintf( text->bv_val, text->bv_len, "next_id failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 ); -#endif return rc; } rc = bdb_dn2id_add( op, tid, ei, e ); @@ -246,13 +237,8 @@ static int bdb_tool_next_id( snprintf( text->bv_val, text->bv_len, "dn2id_add failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, "=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 ); -#endif } else if ( hole ) { if ( nholes == nhmax - 1 ) { if ( holes == hbuf ) { @@ -304,13 +290,8 @@ ID bdb_tool_entry_put( assert( text->bv_val ); assert( text->bv_val[0] == '\0' ); /* overconservative? */ -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ARGS, "=> bdb_tool_entry_put( %ld, \"%s\" )\n", - (long) e->e_id, e->e_dn, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n", - (long) e->e_id, e->e_dn, 0 ); -#endif + Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_tool_entry_put) + "( %ld, \"%s\" )\n", (long) e->e_id, e->e_dn, 0 ); rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid, bdb->bi_db_opflags ); @@ -318,13 +299,9 @@ ID bdb_tool_entry_put( snprintf( text->bv_val, text->bv_len, "txn_begin failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", + "=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n", text->bv_val, 0, 0 ); -#endif return NOID; } @@ -344,13 +321,9 @@ ID bdb_tool_entry_put( snprintf( text->bv_val, text->bv_len, "id2entry_add failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#endif + "=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n", + text->bv_val, 0, 0 ); goto done; } @@ -359,13 +332,9 @@ ID bdb_tool_entry_put( snprintf( text->bv_val, text->bv_len, "index_entry_add failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#endif + "=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n", + text->bv_val, 0, 0 ); goto done; } @@ -376,14 +345,9 @@ done: snprintf( text->bv_val, text->bv_len, "txn_commit failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", + "=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n", text->bv_val, 0, 0 ); -#endif e->e_id = NOID; } @@ -392,14 +356,9 @@ done: snprintf( text->bv_val, text->bv_len, "txn_aborted! %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", + "=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n", text->bv_val, 0, 0 ); -#endif e->e_id = NOID; } @@ -416,40 +375,26 @@ int bdb_tool_entry_reindex( DB_TXN *tid = NULL; Operation op = {0}; -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ARGS, - "=> bdb_tool_entry_reindex( %ld )\n", (long) id, 0, 0 ); -#else - Debug( LDAP_DEBUG_ARGS, "=> bdb_tool_entry_reindex( %ld )\n", + Debug( LDAP_DEBUG_ARGS, + "=> " LDAP_XSTRING(bdb_tool_entry_reindex) "( %ld )\n", (long) id, 0, 0 ); -#endif e = bdb_tool_entry_get( be, id ); if( e == NULL ) { -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, DETAIL1, - "bdb_tool_entry_reindex:: could not locate id=%ld\n", - (long) id, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "bdb_tool_entry_reindex:: could not locate id=%ld\n", + LDAP_XSTRING(bdb_tool_entry_reindex) + ": could not locate id=%ld\n", (long) id, 0, 0 ); -#endif return -1; } rc = TXN_BEGIN( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n", + "=> " LDAP_XSTRING(bdb_tool_entry_reindex) ": " + "txn_begin failed: %s (%d)\n", db_strerror(rc), rc, 0 ); -#endif goto done; } @@ -460,13 +405,9 @@ int bdb_tool_entry_reindex( * */ -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_reindex( %ld, \"%s\" )\n", (long) id, e->e_dn, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_reindex( %ld, \"%s\" )\n", + Debug( LDAP_DEBUG_TRACE, + "=> " LDAP_XSTRING(bdb_tool_entry_reindex) "( %ld, \"%s\" )\n", (long) id, e->e_dn, 0 ); -#endif op.o_bd = be; op.o_tmpmemctx = NULL; @@ -476,15 +417,10 @@ int bdb_tool_entry_reindex( /* add dn2id indices */ rc = bdb_dn2id_add( &op, tid, NULL, e ); if( rc != 0 && rc != DB_KEYEXIST ) { -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_reindex: dn2id_add failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_reindex: dn2id_add failed: %s (%d)\n", + "=> " LDAP_XSTRING(bdb_tool_entry_reindex) + ": dn2id_add failed: %s (%d)\n", db_strerror(rc), rc, 0 ); -#endif goto done; } #endif @@ -495,29 +431,19 @@ done: if( rc == 0 ) { rc = TXN_COMMIT( tid, 0 ); if( rc != 0 ) { -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n", + "=> " LDAP_XSTRING(bdb_tool_entry_reindex) + ": txn_commit failed: %s (%d)\n", db_strerror(rc), rc, 0 ); -#endif e->e_id = NOID; } } else { TXN_ABORT( tid ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, DETAIL1, - "=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n", - db_strerror(rc), rc, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n", + "=> " LDAP_XSTRING(bdb_tool_entry_reindex) + ": txn_aborted! %s (%d)\n", db_strerror(rc), rc, 0 ); -#endif e->e_id = NOID; } bdb_entry_release( &op, e, 0 ); @@ -545,13 +471,9 @@ ID bdb_tool_entry_modify( assert ( e->e_id != NOID ); assert ( e->e_id != 0 ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ARGS, "=> bdb_tool_entry_put( %ld, \"%s\" )\n", + Debug( LDAP_DEBUG_TRACE, + "=> " LDAP_XSTRING(bdb_tool_entry_modify) "( %ld, \"%s\" )\n", (long) e->e_id, e->e_dn, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n", - (long) e->e_id, e->e_dn, 0 ); -#endif rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid, bdb->bi_db_opflags ); @@ -559,13 +481,9 @@ ID bdb_tool_entry_modify( snprintf( text->bv_val, text->bv_len, "txn_begin failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", + "=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n", text->bv_val, 0, 0 ); -#endif return NOID; } @@ -579,13 +497,9 @@ ID bdb_tool_entry_modify( snprintf( text->bv_val, text->bv_len, "id2entry_add failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#endif + "=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n", + text->bv_val, 0, 0 ); goto done; } @@ -594,13 +508,9 @@ ID bdb_tool_entry_modify( snprintf( text->bv_val, text->bv_len, "index_entry_del failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#endif + "=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n", + text->bv_val, 0, 0 ); goto done; } @@ -609,13 +519,9 @@ ID bdb_tool_entry_modify( snprintf( text->bv_val, text->bv_len, "index_entry_add failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#endif + "=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n", + text->bv_val, 0, 0 ); goto done; } @@ -626,14 +532,9 @@ done: snprintf( text->bv_val, text->bv_len, "txn_commit failed: %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", - text->bv_val, 0, 0 ); -#endif + "=> " LDAP_XSTRING(bdb_tool_entry_modify) ": " + "%s\n", text->bv_val, 0, 0 ); e->e_id = NOID; } @@ -642,14 +543,9 @@ done: snprintf( text->bv_val, text->bv_len, "txn_aborted! %s (%d)", db_strerror(rc), rc ); -#ifdef NEW_LOGGING - LDAP_LOG ( TOOLS, ERR, - "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 ); -#else Debug( LDAP_DEBUG_ANY, - "=> bdb_tool_entry_put: %s\n", + "=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n", text->bv_val, 0, 0 ); -#endif e->e_id = NOID; } -- 2.39.5