From aa27cb2262ebf56d5f7a3c9d94f4834177f4cb1c Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 14 Jan 2005 05:49:45 +0000 Subject: [PATCH] Delete obsolete syncprovider stuff --- servers/slapd/back-bdb/Makefile.in | 4 +- servers/slapd/back-bdb/add.c | 38 - servers/slapd/back-bdb/back-bdb.h | 7 - servers/slapd/back-bdb/config.c | 41 -- servers/slapd/back-bdb/ctxcsn.c | 443 ------------ servers/slapd/back-bdb/delete.c | 68 -- servers/slapd/back-bdb/init.c | 67 -- servers/slapd/back-bdb/modify.c | 92 --- servers/slapd/back-bdb/modrdn.c | 89 --- servers/slapd/back-bdb/search.c | 1064 +--------------------------- servers/slapd/back-hdb/Makefile.in | 4 +- 11 files changed, 26 insertions(+), 1891 deletions(-) delete mode 100644 servers/slapd/back-bdb/ctxcsn.c diff --git a/servers/slapd/back-bdb/Makefile.in b/servers/slapd/back-bdb/Makefile.in index a1955be775..f439138a52 100644 --- a/servers/slapd/back-bdb/Makefile.in +++ b/servers/slapd/back-bdb/Makefile.in @@ -18,14 +18,14 @@ SRCS = init.c tools.c config.c \ extended.c referral.c operational.c \ attr.c index.c key.c dbcache.c filterindex.c \ dn2entry.c dn2id.c error.c id2entry.c idl.c \ - nextid.c cache.c trans.c ctxcsn.c + nextid.c cache.c trans.c OBJS = init.lo tools.lo config.lo \ add.lo bind.lo compare.lo delete.lo modify.lo modrdn.lo search.lo \ extended.lo referral.lo operational.lo \ attr.lo index.lo key.lo dbcache.lo filterindex.lo \ dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo \ - nextid.lo cache.lo trans.lo ctxcsn.lo + nextid.lo cache.lo trans.lo LDAP_INCDIR= ../../../include LDAP_LIBDIR= ../../../libraries diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index fdeb3288a1..3a1f6942f4 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -367,19 +367,6 @@ retry: /* transaction retry */ goto return_results; } -#ifdef BDB_PSEARCH - if ( 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 ) { - case BDB_CSN_ABORT : - goto return_results; - case BDB_CSN_RETRY : - goto retry; - } - } -#endif - /* post-read */ if( op->o_postread ) { if( postread_ctrl == NULL ) { @@ -421,31 +408,6 @@ retry: /* transaction retry */ suffix_ei = BEI(e); } -#ifdef BDB_PSEARCH - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - if ( ctxcsn_added ) { - bdb_cache_add( bdb, suffix_ei, ctxcsn_e, - (struct berval *)&slap_ldapsync_cn_bv, locker ); - } - } - - if ( rs->sr_err == LDAP_SUCCESS && !op->o_no_psearch ) { - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - assert( BEI(e) ); - 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 ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_add) - ": persistent search failed " - "(%d,%d)\n", - rc, rs->sr_err, 0 ); - } - } - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - } -#endif - if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) { rs->sr_text = "txn_commit failed"; } else { diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 341d0e9989..d788665c3c 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -23,8 +23,6 @@ LDAP_BEGIN_DECL -#undef BDB_PSEARCH - #define DB_VERSION_FULL ((DB_VERSION_MAJOR << 24) | (DB_VERSION_MINOR << 16) | DB_VERSION_PATCH) #define BDB_SUBENTRIES 1 @@ -184,11 +182,6 @@ struct bdb_info { ID bi_lastid; ldap_pvt_thread_mutex_t bi_lastid_mutex; -#ifdef BDB_PSEARCH - LDAP_LIST_HEAD(pl, slap_op) bi_psearch_list; - ldap_pvt_thread_rdwr_t bi_pslist_rwlock; - LDAP_LIST_HEAD(se, slap_session_entry) bi_session_list; -#endif int bi_idl_cache_max_size; int bi_idl_cache_size; Avlnode *bi_idl_tree; diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index 04d5651423..ec70bf0095 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -194,48 +194,7 @@ bdb_db_config( } if ( !( slapMode & SLAP_TOOL_MODE ) ) bdb->bi_idl_cache_max_size = atoi( argv[1] ); -#ifdef BDB_PSEARCH - } else if ( strcasecmp( argv[0], "sessionlog" ) == 0 ) { - int se_id = 0, se_size = 0; - struct slap_session_entry *sent; - if ( argc < 3 ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: missing arguments in \"sessionlog \"" - " line\n", fname, lineno, 0 ); - return( 1 ); - } - se_id = atoi( argv[1] ); - - if ( se_id < 0 || se_id > 999 ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: session log id %d is out of range [0..999]\n", - fname, lineno , se_id ); - return( 1 ); - } - - se_size = atoi( argv[2] ); - if ( se_size < 0 ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: session log size %d is negative\n", - fname, lineno , se_size ); - return( 1 ); - } - - LDAP_LIST_FOREACH( sent, &bdb->bi_session_list, se_link ) { - if ( sent->se_id == se_id ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: session %d already exists\n", - fname, lineno , se_id ); - return( 1 ); - } - } - sent = (struct slap_session_entry *) ch_calloc( 1, - sizeof( struct slap_session_entry )); - sent->se_id = se_id; - sent->se_size = se_size; - LDAP_LIST_INSERT_HEAD( &bdb->bi_session_list, sent, se_link ); -#endif /* BDB_PSEARCH */ /* anything else */ } else { return SLAP_CONF_UNKNOWN; diff --git a/servers/slapd/back-bdb/ctxcsn.c b/servers/slapd/back-bdb/ctxcsn.c deleted file mode 100644 index 5256623a87..0000000000 --- a/servers/slapd/back-bdb/ctxcsn.c +++ /dev/null @@ -1,443 +0,0 @@ -/* ctxcsn.c -- back-bdb Context CSN Management Routines */ -/* $OpenLDAP$ */ -/* This work is part of OpenLDAP Software . - * - * Copyright 2003-2005 The OpenLDAP Foundation. - * Portions Copyright 2003 IBM Corporation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted only as authorized by the OpenLDAP - * Public License. - * - * A copy of this license is available in the file LICENSE in the - * top-level directory of the distribution or, alternatively, at - * . - */ - -#include "portable.h" - -#include - -#include -#include - -#include "lutil.h" -#include "back-bdb.h" - -#ifdef BDB_PSEARCH -int -bdb_csn_commit( - Operation *op, - SlapReply *rs, - DB_TXN *tid, - EntryInfo *ei, - EntryInfo **suffix_ei, - Entry **ctxcsn_e, - int *ctxcsn_added, - u_int32_t locker -) -{ - struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; - EntryInfo *ctxcsn_ei = NULL; - DB_LOCK ctxcsn_lock; - struct berval max_committed_csn; - DB_LOCK suffix_lock; - int rc, ret; - ID ctxcsn_id; - Entry *e; - char textbuf[SLAP_TEXT_BUFLEN]; - size_t textlen = sizeof textbuf; - EntryInfo *eip = NULL; - - assert( !BER_BVISNULL( &op->o_bd->be_context_csn ) ); - - if ( ei ) { - e = ei->bei_e; - } - - rc = bdb_dn2entry( op, tid, &op->o_bd->be_context_csn, &ctxcsn_ei, - 1, locker, &ctxcsn_lock ); - switch( rc ) { - case 0: - case DB_NOTFOUND: - break; - case DB_LOCK_DEADLOCK: - case DB_LOCK_NOTGRANTED: - return BDB_CSN_RETRY; - default: - return BDB_CSN_ABORT; - } - - *ctxcsn_e = ctxcsn_ei->bei_e; - - slap_get_commit_csn( op, &max_committed_csn ); - - if ( max_committed_csn.bv_val == NULL ) { - return BDB_CSN_COMMIT; - } - - *ctxcsn_added = 0; - - switch( rc ) { - case 0: - if ( !*ctxcsn_e ) { - rs->sr_err = LDAP_OTHER; - rs->sr_text = "context csn not present"; - op->o_tmpfree( max_committed_csn.bv_val, op->o_tmpmemctx ); - return BDB_CSN_ABORT; - } else { - Modifications mod; - struct berval modvals[2]; - Entry dummy; - - modvals[0] = max_committed_csn; - modvals[1].bv_val = NULL; - modvals[1].bv_len = 0; - - mod.sml_op = LDAP_MOD_REPLACE; - mod.sml_values = modvals; - mod.sml_nvalues = NULL; - mod.sml_desc = slap_schema.si_ad_contextCSN; - mod.sml_type = mod.sml_desc->ad_cname; - mod.sml_next = NULL; - - dummy = **ctxcsn_e; - ret = bdb_modify_internal( op, tid, &mod, &dummy, - &rs->sr_text, textbuf, textlen ); - op->o_tmpfree( max_committed_csn.bv_val, op->o_tmpmemctx ); - if ( ret != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_TRACE, - "bdb_csn_commit: modify failed (%d)\n", rs->sr_err, 0, 0 ); - if ( dummy.e_attrs != e->e_attrs ) attrs_free( dummy.e_attrs ); - switch( ret ) { - case DB_LOCK_DEADLOCK: - case DB_LOCK_NOTGRANTED: - goto rewind; - default: - return BDB_CSN_ABORT; - } - } - - ret = bdb_id2entry_update( op->o_bd, tid, &dummy ); - switch ( ret ) { - case 0 : - 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; - } - 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: - if ( op->o_tag == LDAP_REQ_ADD && - be_issuffix( op->o_bd, &op->oq_add.rs_e->e_nname )) { - *suffix_ei = NULL; - eip = (EntryInfo *) ch_calloc( 1, sizeof( EntryInfo )); - eip->bei_id = op->oq_add.rs_e->e_id; - } else { - eip = *suffix_ei = ctxcsn_ei; - } - - /* 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 ) { - Debug( LDAP_DEBUG_TRACE, - "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; - } - - *ctxcsn_e = slap_create_context_csn_entry( op->o_bd, &max_committed_csn ); - op->o_tmpfree( max_committed_csn.bv_val, op->o_tmpmemctx ); - (*ctxcsn_e)->e_id = ctxcsn_id; - *ctxcsn_added = 1; - - ret = bdb_dn2id_add( op, tid, eip, *ctxcsn_e ); - switch ( ret ) { - case 0 : - break; - case DB_LOCK_DEADLOCK : - case DB_LOCK_NOTGRANTED : - goto rewind; - case DB_KEYEXIST : - rs->sr_err = LDAP_OTHER; - rs->sr_text = "context csn exists before context prefix does"; - return BDB_CSN_ABORT; - default : - rs->sr_err = LDAP_OTHER; - rs->sr_text = "context csn store failed"; - return BDB_CSN_ABORT; - } - - if ( *suffix_ei == NULL ) { - ch_free( eip ); - } - - ret = bdb_id2entry_add( op->o_bd, tid, *ctxcsn_e ); - switch ( ret ) { - case 0 : - break; - case DB_LOCK_DEADLOCK : - case DB_LOCK_NOTGRANTED : - goto rewind; - default : - rs->sr_err = LDAP_OTHER; - rs->sr_text = "context csn store failed"; - return BDB_CSN_ABORT; - } - ret = bdb_index_entry_add( op, tid, *ctxcsn_e ); - switch ( ret ) { - case 0 : - break; - case DB_LOCK_DEADLOCK : - case DB_LOCK_NOTGRANTED : - goto rewind; - default : - rs->sr_err = LDAP_OTHER; - rs->sr_text = "context csn indexing failed"; - return BDB_CSN_ABORT; - } - break; - case DB_LOCK_DEADLOCK: - case DB_LOCK_NOTGRANTED: - Debug( LDAP_DEBUG_TRACE, - "bdb_csn_commit : bdb_dn2entry retry\n", 0, 0, 0 ); - goto rewind; - case LDAP_BUSY: - rs->sr_err = rc; - rs->sr_text = "ldap server busy"; - return BDB_CSN_ABORT; - default: - rs->sr_err = LDAP_OTHER; - rs->sr_text = "internal error"; - return BDB_CSN_ABORT; - } - - return BDB_CSN_COMMIT; - -rewind : - slap_rewind_commit_csn( op ); - return BDB_CSN_RETRY; -} - -int -bdb_get_commit_csn( - Operation *op, - SlapReply *rs, - struct berval **search_context_csn, - u_int32_t locker, - DB_LOCK *ctxcsn_lock -) -{ - struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; - struct berval csn = BER_BVNULL; - EntryInfo *ctxcsn_ei = NULL; - EntryInfo *suffix_ei = NULL; - Entry *ctxcsn_e = NULL; - DB_TXN *ltid = NULL; - Attribute *csn_a; - char gid[DB_XIDDATASIZE]; - char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; - int num_retries = 0; - int ctxcsn_added = 0; - int rc; - struct sync_cookie syncCookie = { NULL, -1, NULL}; - syncinfo_t *si; - u_int32_t ctxcsn_locker = 0; - - if ( (op->o_sync_mode & SLAP_SYNC_REFRESH) && - !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - char substr[67]; - struct berval ctxcsn_ndn = BER_BVNULL; - struct berval bv; - - LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) { - sprintf( substr, "cn=syncrepl%ld", si->si_rid ); - ber_str2bv( substr, 0, 0, &bv ); - build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &bv, op->o_tmpmemctx ); - -consumer_ctxcsn_retry : - rs->sr_err = bdb_dn2entry( op, NULL, &ctxcsn_ndn, &ctxcsn_ei, - 0, locker, ctxcsn_lock ); - switch(rs->sr_err) { - case DB_LOCK_DEADLOCK: - case DB_LOCK_NOTGRANTED: - goto consumer_ctxcsn_retry; - case 0: - op->o_tmpfree( ctxcsn_ndn.bv_val, op->o_tmpmemctx ); - ctxcsn_ndn.bv_val = NULL; - if ( ctxcsn_ei ) { - ctxcsn_e = ctxcsn_ei->bei_e; - } - break; - case DB_NOTFOUND: - default: - rs->sr_err = LDAP_OTHER; - case LDAP_BUSY: - op->o_tmpfree( ctxcsn_ndn.bv_val, op->o_tmpmemctx ); - ctxcsn_ndn.bv_val = NULL; - goto done; - } - - if ( ctxcsn_e ) { - csn_a = attr_find( ctxcsn_e->e_attrs, - slap_schema.si_ad_syncreplCookie ); - if ( csn_a ) { - struct berval cookie; - const char *text; - int match = -1; - ber_dupbv( &cookie, &csn_a->a_vals[0] ); - ber_bvarray_add( &syncCookie.octet_str, &cookie ); - slap_parse_sync_cookie( &syncCookie ); - if ( *search_context_csn && - (*search_context_csn)->bv_val != NULL ) - { - value_match( &match, slap_schema.si_ad_entryCSN, - slap_schema.si_ad_entryCSN->ad_type->sat_ordering, - SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, - syncCookie.ctxcsn, *search_context_csn, &text ); - } - if ( match < 0 ) { - /* set search_context_csn to the - smallest syncrepl cookie value */ - if ( *search_context_csn ) { - ch_free( (*search_context_csn)->bv_val ); - ch_free( *search_context_csn ); - } - *search_context_csn = ber_dupbv( NULL, - syncCookie.ctxcsn ); - } - slap_sync_cookie_free( &syncCookie, 0 ); - } else { - *search_context_csn = NULL; - } - } else { - *search_context_csn = NULL; - } - } - } else if ( (op->o_sync_mode & SLAP_SYNC_REFRESH) && - LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - -provider_ctxcsn_retry : - rs->sr_err = bdb_dn2entry( op, NULL, &op->o_bd->be_context_csn, &ctxcsn_ei, - 0, locker, ctxcsn_lock ); - switch(rs->sr_err) { - case 0: - if ( ctxcsn_ei ) { - ctxcsn_e = ctxcsn_ei->bei_e; - } - break; - case LDAP_BUSY: - goto done; - case DB_LOCK_DEADLOCK: - case DB_LOCK_NOTGRANTED: - goto provider_ctxcsn_retry; - case DB_NOTFOUND: - snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx", - bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid ); - - slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 ); - - if ( 0 ) { -txn_retry: - rs->sr_err = TXN_ABORT( ltid ); - ltid = NULL; - if ( rs->sr_err != 0 ) { - rs->sr_err = LDAP_OTHER; - goto done; - } - ldap_pvt_thread_yield(); - bdb_trans_backoff( ++num_retries ); - } - rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, NULL, - <id, bdb->bi_db_opflags ); - if ( rs->sr_err != 0 ) { - rs->sr_err = LDAP_OTHER; - goto done; - } - - ctxcsn_locker = TXN_ID ( ltid ); - - rs->sr_err = bdb_csn_commit( op, rs, ltid, NULL, - &suffix_ei, &ctxcsn_e, - &ctxcsn_added, ctxcsn_locker ); - switch( rs->sr_err ) { - case BDB_CSN_ABORT: - rs->sr_err = LDAP_OTHER; - goto done; - case BDB_CSN_RETRY: - goto txn_retry; - } - - rs->sr_err = TXN_PREPARE( ltid, gid ); - if ( rs->sr_err != 0 ) { - rs->sr_err = LDAP_OTHER; - goto done; - } - - bdb_cache_add( bdb, suffix_ei, ctxcsn_e, - (struct berval *)&slap_ldapsync_cn_bv, ctxcsn_locker ); - - rs->sr_err = TXN_COMMIT( ltid, 0 ); - if ( rs->sr_err != 0 ) { - rs->sr_err = LDAP_OTHER; - goto done; - } - - rs->sr_err = bdb_dn2entry( op, NULL, - &op->o_bd->be_context_csn, - &ctxcsn_ei, 0, ctxcsn_locker, - ctxcsn_lock ); - - if ( ctxcsn_ei ) { - ctxcsn_e = ctxcsn_ei->bei_e; - } - break; - - default: - rs->sr_err = LDAP_OTHER; - goto done; - } - - if ( ctxcsn_e ) { - csn_a = attr_find( ctxcsn_e->e_attrs, - slap_schema.si_ad_contextCSN ); - if ( csn_a ) { - *search_context_csn = ber_dupbv( NULL, &csn_a->a_vals[0] ); - } else { - *search_context_csn = NULL; - } - } else { - *search_context_csn = NULL; - } - } - - ltid = NULL; - rs->sr_err = LDAP_SUCCESS; - -done: - if( ltid != NULL ) { - TXN_ABORT( ltid ); - } - - return rs->sr_err; -} -#endif diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 8937180724..7eacf1fbc4 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -377,22 +377,6 @@ retry: /* transaction retry */ goto return_results; } -#ifdef BDB_PSEARCH - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) { - rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_PREDELETE ); - if ( rc == LDAP_BUSY && op->o_ps_send_wait ) { - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - goto retry; - } else if ( rc ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_delete) ": persistent search " - "failed (%d,%d)\n", rc, rs->sr_err, 0 ); - } - } - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); -#endif - /* delete from dn2id */ rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e ); if ( rs->sr_err != 0 ) { @@ -482,21 +466,6 @@ retry: /* transaction retry */ ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex ); #endif -#ifdef BDB_PSEARCH - 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 ) { - case BDB_CSN_ABORT : - goto return_results; - case BDB_CSN_RETRY : - goto retry; - } - } -#endif - if( op->o_noop ) { if ( ( rs->sr_err = TXN_ABORT( ltid ) ) != 0 ) { rs->sr_text = "txn_abort (no-op) failed"; @@ -513,43 +482,6 @@ retry: /* transaction retry */ goto retry; } -#ifdef BDB_PSEARCH - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - if ( ctxcsn_added ) { - bdb_cache_add( bdb, suffix_ei, - ctxcsn_e, (struct berval *)&slap_ldapsync_cn_bv, locker ); - } - } - - if ( rs->sr_err == LDAP_SUCCESS && !op->o_no_psearch ) { - Attribute *a; - a = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN ); - if ( a ) { - if( (void *) e->e_attrs != (void *) (e+1)) { - attr_delete( &e->e_attrs, slap_schema.si_ad_entryCSN ); - attr_merge_normalize_one( e, slap_schema.si_ad_entryCSN, - &op->o_sync_csn, NULL ); - } else { - a->a_vals[0] = op->o_sync_csn; - } - } else { - /* Hm, the entryCSN ought to exist. ??? */ - } - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - 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 ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_delete) - ": persistent search failed " - "(%d,%d)\n", - rc, rs->sr_err, 0 ); - } - } - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - } -#endif - rs->sr_err = TXN_COMMIT( ltid, 0 ); } ltid = NULL; diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 5e92a5544a..188464e42a 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -85,11 +85,6 @@ bdb_db_init( BackendDB *be ) bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH; bdb->bi_search_stack = NULL; -#ifdef BDB_PSEARCH - LDAP_LIST_INIT (&bdb->bi_psearch_list); - ldap_pvt_thread_rdwr_init ( &bdb->bi_pslist_rwlock ); -#endif - ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex ); ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex ); ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex ); @@ -468,68 +463,6 @@ bdb_db_destroy( BackendDB *be ) ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock ); } -#ifdef BDB_PSEARCH - ldap_pvt_thread_rdwr_destroy ( &bdb->bi_pslist_rwlock ); - ps = LDAP_LIST_FIRST( &bdb->bi_psearch_list ); - - if ( ps ) { - psn = LDAP_LIST_NEXT( ps, o_ps_link ); - - saved_tmpmemctx = ps->o_tmpmemctx; - - if (!BER_BVISNULL(&ps->o_req_dn)) { - slap_sl_free( ps->o_req_dn.bv_val, ps->o_tmpmemctx ); - } - if (!BER_BVISNULL(&ps->o_req_ndn)) { - slap_sl_free( ps->o_req_ndn.bv_val, ps->o_tmpmemctx ); - } - if (!BER_BVISNULL(&ps->ors_filterstr)) { - slap_sl_free(ps->ors_filterstr.bv_val, ps->o_tmpmemctx); - } - if (ps->ors_filter != NULL) { - filter_free_x(ps, ps->ors_filter); - } - if ( ps->ors_attrs != NULL) { - ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx); - } - - slap_op_free( ps ); - - if ( saved_tmpmemctx ) { - slap_sl_mem_destroy( NULL, saved_tmpmemctx ); - } - } - - while ( psn ) { - ps = psn; - psn = LDAP_LIST_NEXT( ps, o_ps_link ); - - saved_tmpmemctx = ps->o_tmpmemctx; - - if (!BER_BVISNULL(&ps->o_req_dn)) { - slap_sl_free( ps->o_req_dn.bv_val, ps->o_tmpmemctx ); - } - if (!BER_BVISNULL(&ps->o_req_ndn)) { - slap_sl_free( ps->o_req_ndn.bv_val, ps->o_tmpmemctx ); - } - if (!BER_BVISNULL(&ps->ors_filterstr)) { - slap_sl_free(ps->ors_filterstr.bv_val, ps->o_tmpmemctx); - } - if (ps->ors_filter != NULL) { - filter_free_x(ps, ps->ors_filter); - } - if ( ps->ors_attrs != NULL) { - ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx); - } - - slap_op_free( ps ); - - if ( saved_tmpmemctx ) { - slap_sl_mem_destroy( NULL, saved_tmpmemctx ); - } - } -#endif - ch_free( bdb ); be->be_private = NULL; diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 4ad218ac14..9bdf51fde6 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -307,16 +307,6 @@ retry: /* transaction retry */ Debug(LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modify) ": retrying...\n", 0, 0, 0); -#ifdef BDB_PSEARCH - pm_list = LDAP_LIST_FIRST(&op->o_pm_list); - while ( pm_list != NULL ) { - LDAP_LIST_REMOVE ( pm_list, ps_link ); - pm_prev = pm_list; - pm_list = LDAP_LIST_NEXT ( pm_list, ps_link ); - ch_free( pm_prev ); - } -#endif - rs->sr_err = TXN_ABORT( ltid ); ltid = NULL; op->o_private = NULL; @@ -447,25 +437,6 @@ retry: /* transaction retry */ goto return_results; } -#ifdef BDB_PSEARCH - if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop && !op->o_no_psearch ) { - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - 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 == LDAP_BUSY && op->o_ps_send_wait ) { - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - goto retry; - } else if ( rc ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_modify) - ": persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); - } - } - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - } -#endif - if( op->o_preread ) { if( preread_ctrl == NULL ) { preread_ctrl = &ctrls[num_ctrls++]; @@ -537,19 +508,6 @@ retry: /* transaction retry */ goto return_results; } -#ifdef BDB_PSEARCH - if ( 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 ) { - case BDB_CSN_ABORT : - goto return_results; - case BDB_CSN_RETRY : - goto retry; - } - } -#endif - if( op->o_postread ) { if( postread_ctrl == NULL ) { postread_ctrl = &ctrls[num_ctrls++]; @@ -583,47 +541,6 @@ retry: /* transaction retry */ } dummy.e_attrs = NULL; -#ifdef BDB_PSEARCH - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - if ( ctxcsn_added ) { - bdb_cache_add( bdb, suffix_ei, ctxcsn_e, - (struct berval *)&slap_ldapsync_cn_bv, locker ); - } - } - - if ( rs->sr_err == LDAP_SUCCESS ) { - /* Loop through in-scope entries for each psearch spec */ - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - 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 ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_modify) - ": persistent search failed " - "(%d,%d)\n", - rc, rs->sr_err, 0 ); - } - } - 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 ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_modify) - ": persistent search failed " - "(%d,%d)\n", - rc, rs->sr_err, 0 ); - } - LDAP_LIST_REMOVE ( pm_list, ps_link ); - pm_prev = pm_list; - pm_list = LDAP_LIST_NEXT ( pm_list, ps_link ); - ch_free( pm_prev ); - } - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - } -#endif - rs->sr_err = TXN_COMMIT( ltid, 0 ); } ltid = NULL; @@ -663,15 +580,6 @@ return_results: done: if( ltid != NULL ) { -#ifdef BDB_PSEARCH - pm_list = LDAP_LIST_FIRST(&op->o_pm_list); - while ( pm_list != NULL ) { - LDAP_LIST_REMOVE ( pm_list, ps_link ); - pm_prev = pm_list; - pm_list = LDAP_LIST_NEXT ( pm_list, ps_link ); - ch_free( pm_prev ); - } -#endif TXN_ABORT( ltid ); op->o_private = NULL; } diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index b7ebd0bbff..51e7399410 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -100,15 +100,6 @@ retry: /* transaction retry */ } Debug( LDAP_DEBUG_TRACE, "==>" LDAP_XSTRING(bdb_modrdn) ": retrying...\n", 0, 0, 0 ); -#ifdef BDB_PSEARCH - pm_list = LDAP_LIST_FIRST(&op->o_pm_list); - while ( pm_list != NULL ) { - LDAP_LIST_REMOVE ( pm_list, ps_link ); - pm_prev = pm_list; - pm_list = LDAP_LIST_NEXT ( pm_list, ps_link ); - ch_free( pm_prev ); - } -#endif rs->sr_err = TXN_ABORT( ltid ); ltid = NULL; @@ -720,23 +711,6 @@ retry: /* transaction retry */ dummy.e_attrs = e->e_attrs; -#ifdef BDB_PSEARCH - if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop && !op->o_no_psearch ) { - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - 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 ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_modrdn) - ": persistent search failed (%d,%d)\n", - rc, rs->sr_err, 0 ); - } - } - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - } -#endif - - /* modify entry */ rs->sr_err = bdb_modify_internal( op, lt2, &mod[0], &dummy, &rs->sr_text, textbuf, textlen ); @@ -805,19 +779,6 @@ retry: /* transaction retry */ goto return_results; } -#ifdef BDB_PSEARCH - if ( 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 ) { - case BDB_CSN_ABORT : - goto return_results; - case BDB_CSN_RETRY : - goto retry; - } - } -#endif - if( op->o_postread ) { if( postread_ctrl == NULL ) { postread_ctrl = &ctrls[num_ctrls++]; @@ -853,47 +814,6 @@ retry: /* transaction retry */ new_dn.bv_val = NULL; new_ndn.bv_val = NULL; -#ifdef BDB_PSEARCH - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - if ( ctxcsn_added ) { - bdb_cache_add( bdb, suffix_ei, ctxcsn_e, - (struct berval *)&slap_ldapsync_cn_bv, locker ); - } - } - - if ( rs->sr_err == LDAP_SUCCESS ) { - /* Loop through in-scope entries for each psearch spec */ - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - 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 ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_modrdn) - ": persistent search failed " - "(%d,%d)\n", - rc, rs->sr_err, 0 ); - } - } - 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 ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_modrdn) - ": persistent search failed " - "(%d,%d)\n", - rc, rs->sr_err, 0 ); - } - pm_prev = pm_list; - LDAP_LIST_REMOVE ( pm_list, ps_link ); - pm_list = LDAP_LIST_NEXT ( pm_list, ps_link ); - ch_free( pm_prev ); - } - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - } -#endif - if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) { rs->sr_text = "txn_commit failed"; } else { @@ -980,15 +900,6 @@ done: } if( ltid != NULL ) { -#ifdef BDB_PSEARCH - pm_list = LDAP_LIST_FIRST(&op->o_pm_list); - while ( pm_list != NULL ) { - LDAP_LIST_REMOVE ( pm_list, ps_link ); - pm_prev = pm_list; - pm_list = LDAP_LIST_NEXT ( pm_list, ps_link ); - ch_free( pm_prev ); - } -#endif TXN_ABORT( ltid ); op->o_private = NULL; } diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 59f9646ed0..3f090595db 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -302,307 +302,10 @@ sameido: return rs->sr_err; } -#ifdef BDB_PSEARCH - -#define is_sync_protocol(op) \ - ((op)->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST) - -#define IS_BDB_REPLACE(type) (( type == LDAP_PSEARCH_BY_DELETE ) || \ - ( type == LDAP_PSEARCH_BY_SCOPEOUT )) -#define IS_PSEARCH (op != sop) -#define IS_POST_SEARCH ( op->ors_post_search_id != NOID ) - -static Operation * -bdb_drop_psearch( Operation *op, ber_int_t msgid ) -{ - Operation *ps_list; - struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; - - LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) { - if ( ps_list->o_connid == op->o_connid ) { - if ( ps_list->o_msgid == msgid ) { - ps_list->o_abandon = 1; - LDAP_LIST_REMOVE( ps_list, o_ps_link ); - ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); - LDAP_STAILQ_REMOVE( &op->o_conn->c_ops, ps_list, - slap_op, o_next ); - LDAP_STAILQ_NEXT( ps_list, o_next ) = NULL; - op->o_conn->c_n_ops_executing--; - op->o_conn->c_n_ops_completed++; - ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex ); - return ps_list; - } - } - } - - return NULL; -} - -int -bdb_abandon( Operation *op, SlapReply *rs ) -{ - Operation *ps; - void *saved_tmpmemctx; - - ps = bdb_drop_psearch( op, op->oq_abandon.rs_msgid ); - if ( ps ) { - saved_tmpmemctx = ps->o_tmpmemctx; - - if (!BER_BVISNULL(&ps->o_req_dn)) { - slap_sl_free(ps->o_req_dn.bv_val, ps->o_tmpmemctx ); - } - if (!BER_BVISNULL(&ps->o_req_ndn)) { - slap_sl_free(ps->o_req_ndn.bv_val, ps->o_tmpmemctx ); - } - if (!BER_BVISNULL(&ps->ors_filterstr)) { - ps->o_tmpfree(ps->ors_filterstr.bv_val, ps->o_tmpmemctx); - } - if (ps->ors_filter != NULL) { - filter_free_x(ps, ps->ors_filter); - } - if (ps->ors_attrs != NULL) { - ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx); - } - - slap_op_free ( ps ); - - if ( saved_tmpmemctx ) { - slap_sl_mem_destroy( NULL, saved_tmpmemctx ); - } - - return LDAP_SUCCESS; - } - return LDAP_UNAVAILABLE; -} - -int -bdb_cancel( Operation *op, SlapReply *rs ) -{ - Operation *ps; - void *saved_tmpmemctx; - - ps = bdb_drop_psearch( op, op->oq_cancel.rs_msgid ); - if ( ps ) { - saved_tmpmemctx = ps->o_tmpmemctx; - - rs->sr_err = LDAP_CANCELLED; - send_ldap_result( ps, rs ); - - if (!BER_BVISNULL(&ps->o_req_dn)) { - slap_sl_free(ps->o_req_dn.bv_val, ps->o_tmpmemctx ); - } - if (!BER_BVISNULL(&ps->o_req_ndn)) { - slap_sl_free(ps->o_req_ndn.bv_val, ps->o_tmpmemctx ); - } - if (!BER_BVISNULL(&ps->ors_filterstr)) { - ps->o_tmpfree(ps->ors_filterstr.bv_val, ps->o_tmpmemctx); - } - if (ps->ors_filter != NULL) { - filter_free_x(ps, ps->ors_filter); - } - if (ps->ors_attrs != NULL) { - ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx); - } - - slap_op_free ( ps ); - - if ( saved_tmpmemctx ) { - slap_sl_mem_destroy( NULL, saved_tmpmemctx ); - } - - return LDAP_SUCCESS; - } - return LDAP_UNAVAILABLE; -} - -int bdb_search( Operation *op, SlapReply *rs ) -{ - int rc; - struct pc_entry *pce = NULL; - struct pc_entry *tmp_pce = NULL; - Entry ps_e = {0}; - Attribute *a; - - ps_e.e_private = NULL; - ldap_pvt_thread_mutex_init( &op->o_pcmutex ); - LDAP_TAILQ_INIT( &op->o_ps_pre_candidates ); - LDAP_TAILQ_INIT( &op->o_ps_post_candidates ); - - op->ors_post_search_id = NOID; - rc = bdb_do_search( op, rs, op, NULL, 0 ); - - ldap_pvt_thread_mutex_lock( &op->o_pcmutex ); - pce = LDAP_TAILQ_FIRST( &op->o_ps_post_candidates ); - ldap_pvt_thread_mutex_unlock( &op->o_pcmutex ); - - while ( rc == LDAP_SUCCESS && pce && - op->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST ) { - - ps_e.e_id = op->ors_post_search_id = pce->pc_id; - if ( op->o_sync_csn.bv_val ) { - ch_free( op->o_sync_csn.bv_val ); - op->o_sync_csn.bv_val = NULL; - } - ber_dupbv( &op->o_sync_csn, &pce->pc_csn ); - ber_dupbv( &ps_e.e_name, &pce->pc_ename ); - ber_dupbv( &ps_e.e_nname, &pce->pc_enname ); - a = ch_calloc( 1, sizeof( Attribute )); - a->a_desc = slap_schema.si_ad_entryUUID; - a->a_vals = ch_calloc( 2, sizeof( struct berval )); - ber_dupbv( &a->a_vals[0], &pce->pc_entryUUID ); - a->a_nvals = a->a_vals; - a->a_next = NULL; - ps_e.e_attrs = a; - - rc = bdb_do_search( op, rs, op, &ps_e, 0 ); - - tmp_pce = pce; - ldap_pvt_thread_mutex_lock( &op->o_pcmutex ); - pce = LDAP_TAILQ_NEXT( pce, pc_link ); - LDAP_TAILQ_REMOVE( &op->o_ps_post_candidates, tmp_pce, pc_link ); - ldap_pvt_thread_mutex_unlock( &op->o_pcmutex ); - - ch_free( tmp_pce->pc_csn.bv_val ); - ch_free( tmp_pce->pc_entryUUID.bv_val ); - ch_free( tmp_pce->pc_ename.bv_val ); - ch_free( tmp_pce->pc_enname.bv_val ); - ch_free( tmp_pce ); - entry_clean( &ps_e ); - } - return rc; -} - -#define BDB_PSEARCH_MAX_WAIT 3 -int bdb_psearch( Operation *op, SlapReply *rs, Operation *sop, - Entry *ps_e, int ps_type ) -{ - int rc; - struct pc_entry *pce = NULL; - struct pc_entry *p = NULL; - int num_retries = 0; - - op->ors_post_search_id = NOID; - - switch (ps_type) { - case LDAP_PSEARCH_BY_PREMODIFY: - case LDAP_PSEARCH_BY_PREDELETE: - - if ( !op->o_ps_send_wait ) { - if ( sop->o_refresh_in_progress ) { - pce = (struct pc_entry *) ch_calloc( - 1, sizeof( struct pc_entry )); - pce->pc_id = ps_e->e_id; - ldap_pvt_thread_mutex_lock( &sop->o_pcmutex ); - if ( LDAP_TAILQ_EMPTY( &sop->o_ps_pre_candidates )) { - LDAP_TAILQ_INSERT_HEAD( - &sop->o_ps_pre_candidates, pce, pc_link ); - } else { - LDAP_TAILQ_FOREACH( p, - &sop->o_ps_pre_candidates, pc_link ) { - if ( p->pc_id > pce->pc_id ) - break; - } - - if ( p ) { - LDAP_TAILQ_INSERT_BEFORE( p, pce, pc_link ); - } else { - LDAP_TAILQ_INSERT_TAIL( - &sop->o_ps_pre_candidates, - pce, pc_link ); - } - } - ldap_pvt_thread_mutex_unlock( &sop->o_pcmutex ); - } else { - rc = bdb_do_search( op, rs, sop, ps_e, ps_type ); - return rc; - } - } else { - pce = op->o_ps_send_wait; - } - - /* Wait until refresh search send the entry */ - while ( !pce->pc_sent ) { - if ( sop->o_refresh_in_progress ) { - if ( num_retries == BDB_PSEARCH_MAX_WAIT ) { - op->o_ps_send_wait = pce; - return LDAP_BUSY; - } - ldap_pvt_thread_yield(); - bdb_trans_backoff( ++num_retries ); - } else { - break; - } - } - - op->o_ps_send_wait = NULL; - - if ( !sop->o_refresh_in_progress && !pce->pc_sent ) { - /* refresh ended without processing pce */ - /* need to perform psearch for ps_e */ - ldap_pvt_thread_mutex_lock( &sop->o_pcmutex ); - LDAP_TAILQ_REMOVE( &sop->o_ps_pre_candidates, pce, pc_link ); - ldap_pvt_thread_mutex_unlock( &sop->o_pcmutex ); - ch_free( pce ); - rc = bdb_do_search( op, rs, sop, ps_e, ps_type ); - return rc; - } else { - /* the pce entry was sent in the refresh phase */ - if ( ps_type == LDAP_PSEARCH_BY_PREMODIFY ) { - struct psid_entry* psid_e; - psid_e = (struct psid_entry *) ch_calloc(1, - sizeof(struct psid_entry)); - psid_e->ps_op = sop; - LDAP_LIST_INSERT_HEAD( &op->o_pm_list, psid_e, ps_link ); - } - - ldap_pvt_thread_mutex_lock( &sop->o_pcmutex ); - LDAP_TAILQ_REMOVE( &sop->o_ps_pre_candidates, pce, pc_link ); - ldap_pvt_thread_mutex_unlock( &sop->o_pcmutex ); - ch_free( pce ); - return LDAP_SUCCESS; - } - break; - case LDAP_PSEARCH_BY_DELETE: - case LDAP_PSEARCH_BY_SCOPEOUT: - case LDAP_PSEARCH_BY_ADD: - case LDAP_PSEARCH_BY_MODIFY: - ldap_pvt_thread_mutex_lock( &op->o_pcmutex ); - if ( sop->o_refresh_in_progress || - !LDAP_TAILQ_EMPTY( &sop->o_ps_post_candidates )) { - pce = (struct pc_entry *) ch_calloc( 1, sizeof( struct pc_entry )); - pce->pc_id = ps_e->e_id; - ber_dupbv( &pce->pc_csn, &op->o_sync_csn ); - if ( ps_type == LDAP_PSEARCH_BY_DELETE ) { - Attribute *a; - for ( a = ps_e->e_attrs; a != NULL; a = a->a_next ) { - AttributeDescription *desc = a->a_desc; - if ( desc == slap_schema.si_ad_entryUUID ) { - ber_dupbv( &pce->pc_entryUUID, &a->a_nvals[0] ); - } - } - } - ber_dupbv( &pce->pc_ename, &ps_e->e_name ); - ber_dupbv( &pce->pc_enname, &ps_e->e_nname ); - LDAP_TAILQ_INSERT_TAIL( &sop->o_ps_post_candidates, pce, pc_link ); - ldap_pvt_thread_mutex_unlock( &op->o_pcmutex ); - } else { - ldap_pvt_thread_mutex_unlock( &op->o_pcmutex ); - rc = bdb_do_search( op, rs, sop, ps_e, ps_type ); - return rc; - } - break; - default: - Debug( LDAP_DEBUG_TRACE, "do_psearch: invalid psearch type\n", - 0, 0, 0 ); - return LDAP_OTHER; - } -} -#else int bdb_search( Operation *op, SlapReply *rs ) { return bdb_do_search( op, rs, op, NULL, 0 ); } -#endif /* For persistent searches, op is the currently executing operation, * sop is the persistent search. For regular searches, sop = op. @@ -630,137 +333,13 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop, struct bdb_op_info *opinfo = NULL; DB_TXN *ltid = NULL; -#ifdef BDB_PSEARCH - Filter contextcsnand, contextcsnle, cookief, csnfnot, - csnfeq, csnfand, csnfge; - AttributeAssertion aa_ge, aa_eq, aa_le; - struct berval *search_context_csn = NULL; - DB_LOCK ctxcsn_lock; - LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS]; - int num_ctrls = 0; - AttributeName uuid_attr[2]; - int rc_sync = 0; - int entry_sync_state = -1; - AttributeName null_attr; - int no_sync_state_change = 0; - - - Operation *ps_list; - int sync_send_present_mode = 1; - int match; - MatchingRule *mr; - const char *text; - int slog_found = 0; - - struct pc_entry *pce = NULL; - BerVarray syncUUID_set = NULL; - int syncUUID_set_cnt = 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; -#ifdef BDB_PSEARCH - if ( !IS_POST_SEARCH && !IS_PSEARCH && - sop->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST ) { - struct slap_session_entry *sent; - if ( sop->o_sync_state.sid >= 0 ) { - LDAP_LIST_FOREACH( sent, &bdb->bi_session_list, se_link ) { - if ( sent->se_id == sop->o_sync_state.sid ) { - sop->o_sync_slog_size = sent->se_size; - break; - } - } - } - } - - /* psearch needs to be registered before refresh begins */ - if ( !IS_POST_SEARCH && !IS_PSEARCH && - sop->o_sync_mode & SLAP_SYNC_PERSIST ) { - sop->o_refresh_in_progress = 1; - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - LDAP_LIST_INSERT_HEAD( &bdb->bi_psearch_list, sop, o_ps_link ); - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - - } else if ( !IS_POST_SEARCH && !IS_PSEARCH && - sop->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST - && sop->o_sync_slog_size >= 0 ) - { - ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); - LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) { - if ( ps_list->o_sync_slog_size >= 0 ) { - if ( ps_list->o_sync_state.sid == sop->o_sync_state.sid ) { - slog_found = 1; - break; - } - } - } - - if ( slog_found ) { - if ( ps_list->o_sync_slog_omitcsn.bv_len != 0 ) { - mr = slap_schema.si_ad_entryCSN->ad_type->sat_ordering; - if ( sop->o_sync_state.ctxcsn && - sop->o_sync_state.ctxcsn->bv_val != NULL ) - { - value_match( &match, slap_schema.si_ad_entryCSN, mr, - SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, - sop->o_sync_state.ctxcsn, - &ps_list->o_sync_slog_omitcsn, - &text ); - } else { - match = -1; - } - if ( match >= 0 ) { - sync_send_present_mode = 0; - } - } else { - sync_send_present_mode = 0; - } - } else if ( sop->o_sync_slog_size >= 0 ) { - LDAP_LIST_INSERT_HEAD( &bdb->bi_psearch_list, sop, o_ps_link ); - } else { - sop->o_sync_state.sid = -1; - } - ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); - } - - null_attr.an_desc = NULL; - null_attr.an_oc = NULL; - null_attr.an_oc_exclude = 0; - BER_BVZERO( &null_attr.an_name ); - - for( num_ctrls = 0; num_ctrls < SLAP_MAX_RESPONSE_CONTROLS; num_ctrls++ ) { - ctrls[num_ctrls] = NULL; - } - num_ctrls = 0; - - if ( IS_PSEARCH && IS_BDB_REPLACE(ps_type)) { - attrs = uuid_attr; - attrs[0].an_desc = NULL; - attrs[0].an_oc = NULL; - attrs[0].an_oc_exclude = 0; - BER_BVZERO( &attrs[0].an_name ); - } -#endif - manageDSAit = get_manageDSAit( sop ); -#ifdef BDB_PSEARCH - /* Sync control overrides manageDSAit */ - if ( !IS_PSEARCH && sop->o_sync_mode & SLAP_SYNC_REFRESH ) { - if ( manageDSAit == SLAP_CONTROL_NONE ) { - manageDSAit = SLAP_CONTROL_CRITICAL; - } - } else if ( IS_PSEARCH ) { - if ( manageDSAit == SLAP_CONTROL_NONE ) { - manageDSAit = SLAP_CONTROL_CRITICAL; - } - } -#endif - if ( opinfo && opinfo->boi_txn ) { ltid = opinfo->boi_txn; locker = TXN_ID( ltid ); @@ -776,16 +355,6 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop, } } -#ifdef BDB_PSEARCH - if ( IS_POST_SEARCH ) { - cursor = 0; - candidates[0] = 1; - candidates[1] = op->ors_post_search_id; - search_context_csn = ber_dupbv( NULL, &op->o_sync_csn ); - goto loop_start; - } -#endif - if ( sop->o_req_ndn.bv_len == 0 ) { /* DIT root special case */ ei_root.bei_e = &e_root; @@ -983,30 +552,6 @@ dn2entry_retry: } e = NULL; -#ifdef BDB_PSEARCH - if ( !IS_PSEARCH ) { - rs->sr_err = bdb_get_commit_csn( sop, rs, &search_context_csn, - locker, &ctxcsn_lock ); - - if ( rs->sr_err != LDAP_SUCCESS ) { - send_ldap_error( sop, rs, rs->sr_err, - "error in csn management in search" ); - goto done; - } - - if ( sop->o_sync_mode != SLAP_SYNC_NONE && - sop->o_sync_state.ctxcsn && - sop->o_sync_state.ctxcsn->bv_val && - ber_bvcmp( &sop->o_sync_state.ctxcsn[0], search_context_csn ) == 0 ) - { - bdb_cache_entry_db_unlock( bdb->bi_dbenv, &ctxcsn_lock ); - goto nochange; - } - } else { - search_context_csn = ber_dupbv( NULL, &op->o_sync_csn ); - } -#endif - /* select candidates */ if ( sop->oq_search.rs_scope == LDAP_SCOPE_BASE ) { rs->sr_err = base_candidate( op->o_bd, &base, candidates ); @@ -1018,33 +563,9 @@ dn2entry_retry: locker, candidates, scopes ); } -#ifdef BDB_PSEARCH - if ( !IS_PSEARCH && sop->o_sync_mode != SLAP_SYNC_NONE ) { - bdb_cache_entry_db_unlock( bdb->bi_dbenv, &ctxcsn_lock ); - } -#endif - /* start cursor at beginning of candidates. */ cursor = 0; -#ifdef BDB_PSEARCH - if (IS_PSEARCH) { - if ( !BDB_IDL_IS_RANGE( candidates ) ) { - cursor = bdb_idl_search( candidates, ps_e->e_id ); - if ( candidates[cursor] != ps_e->e_id ) { - rs->sr_err = LDAP_SUCCESS; - goto done; - } - } else if ( ps_e->e_id < BDB_IDL_RANGE_FIRST( candidates ) || - ps_e->e_id > BDB_IDL_RANGE_LAST( candidates )) - { - rs->sr_err = LDAP_SUCCESS; - goto done; - } - candidates[0] = 1; - candidates[1] = ps_e->e_id; - } -#endif if ( candidates[0] == 0 ) { Debug( LDAP_DEBUG_TRACE, @@ -1112,157 +633,21 @@ dn2entry_retry: goto loop_begin; } -#ifdef BDB_PSEARCH - if (( sop->o_sync_mode & SLAP_SYNC_REFRESH ) || IS_PSEARCH ) { - int match; - - cookief.f_choice = LDAP_FILTER_AND; - cookief.f_and = &csnfnot; - cookief.f_next = NULL; - - csnfnot.f_choice = LDAP_FILTER_NOT; - csnfnot.f_not = &csnfeq; - csnfnot.f_next = &csnfand; - - csnfeq.f_choice = LDAP_FILTER_EQUALITY; - csnfeq.f_ava = &aa_eq; - csnfeq.f_av_desc = slap_schema.si_ad_entryCSN; - if ( sop->o_sync_state.ctxcsn != NULL ) { - csnfeq.f_av_value = *sop->o_sync_state.ctxcsn; - } else { - csnfeq.f_av_value = slap_empty_bv; - } - - csnfand.f_choice = LDAP_FILTER_AND; - csnfand.f_and = &csnfge; - csnfand.f_next = NULL; - - csnfge.f_choice = LDAP_FILTER_GE; - csnfge.f_ava = &aa_ge; - csnfge.f_av_desc = slap_schema.si_ad_entryCSN; - if ( sop->o_sync_state.ctxcsn != NULL ) { - csnfge.f_av_value = *sop->o_sync_state.ctxcsn; - } else { - csnfge.f_av_value = slap_empty_bv; - } - - if ( search_context_csn && !IS_PSEARCH ) { - csnfge.f_next = &contextcsnand; - - contextcsnand.f_choice = LDAP_FILTER_AND; - contextcsnand.f_and = &contextcsnle; - contextcsnand.f_next = NULL; - - contextcsnle.f_choice = LDAP_FILTER_LE; - contextcsnle.f_ava = &aa_le; - contextcsnle.f_av_desc = slap_schema.si_ad_entryCSN; - contextcsnle.f_av_value = *search_context_csn; - contextcsnle.f_next = sop->oq_search.rs_filter; - - mr = slap_schema.si_ad_entryCSN->ad_type->sat_ordering; - if ( sop->o_sync_state.ctxcsn && - sop->o_sync_state.ctxcsn->bv_val != NULL ) - { - value_match( &match, slap_schema.si_ad_entryCSN, mr, - SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, - &sop->o_sync_state.ctxcsn[0], search_context_csn, - &text ); - } else { - match = -1; - } - no_sync_state_change = ( match >= 0 ); - } else { - csnfge.f_next = sop->oq_search.rs_filter; - } - } -#endif - loop_start: for ( id = bdb_idl_first( candidates, &cursor ); - id != NOID -#ifdef BDB_PSEARCH - && !no_sync_state_change -#endif - ; id = bdb_idl_next( candidates, &cursor ) ) + id != NOID ; id = bdb_idl_next( candidates, &cursor ) ) { int scopeok = 0; ID* idhole = NULL; loop_begin: -#ifdef BDB_PSEARCH - if ( !IS_POST_SEARCH ) { - idhole = (ID*) avl_find( sop->o_psearch_finished, - (caddr_t)&id, bdb_pfid_cmp ); - if ( idhole ) { - avl_delete( &sop->o_psearch_finished, - (caddr_t)idhole, bdb_pfid_cmp ); - sop->o_tmpfree( idhole, sop->o_tmpmemctx ); - goto loop_continue; - } - - if ( sop->o_refresh_in_progress ) { - ldap_pvt_thread_mutex_lock( &sop->o_pcmutex ); - pce = LDAP_TAILQ_FIRST( &sop->o_ps_pre_candidates ); - while ( pce && pce->pc_sent ) { - pce = LDAP_TAILQ_NEXT( pce, pc_link ); - } - ldap_pvt_thread_mutex_unlock( &sop->o_pcmutex ); - if ( pce ) { - ID pos; - if ( BDB_IDL_IS_RANGE( candidates ) ) { - if ( pce->pc_id >= candidates[1] && - pce->pc_id <= candidates[2] && - pce->pc_id > cursor-1 ) { - id = pce->pc_id; - cursor--; - avl_insert( &sop->o_psearch_finished, - (caddr_t)bdb_id_dup( sop, &pce->pc_id ), - bdb_pfid_cmp, avl_dup_error ); - } else { - pce->pc_sent = 1; - } - } else { - pos = bdb_idl_search(candidates, pce->pc_id); - if ( pos > cursor-1 && pos <= candidates[0] ) { - id = pce->pc_id; - cursor--; - avl_insert( &sop->o_psearch_finished, - (caddr_t)bdb_id_dup( sop, &pce->pc_id ), - bdb_pfid_cmp, avl_dup_error ); - } else { - pce->pc_sent = 1; - } - } - } - } - } - - /* check for abandon */ - if ( sop->o_abandon ) { - if ( sop != op ) { - bdb_drop_psearch( sop, sop->o_msgid ); - } - rs->sr_err = LDAP_SUCCESS; - goto done; - } - - if ( sop->o_cancel ) { - assert( sop->o_cancel == SLAP_CANCEL_REQ ); - rs->sr_err = LDAP_CANCELLED; - send_ldap_result( sop, rs ); - sop->o_cancel = SLAP_CANCEL_ACK; - rs->sr_err = LDAP_SUCCESS; - goto done; - } -#else /* check for abandon */ if ( sop->o_abandon ) { rs->sr_err = LDAP_SUCCESS; goto done; } -#endif /* check time limit */ if ( sop->ors_tlimit != SLAP_NO_LIMIT @@ -1275,9 +660,6 @@ loop_begin: goto done; } -#ifdef BDB_PSEARCH - if (!IS_PSEARCH) { -#endif fetch_entry_retry: /* get the entry with reader lock */ ei = NULL; @@ -1302,13 +684,6 @@ fetch_entry_retry: } if ( e == NULL ) { -#ifdef BDB_PSEARCH - if ( IS_POST_SEARCH ) { - /* send LDAP_SYNC_DELETE */ - rs->sr_entry = e = ps_e; - goto post_search_no_entry; - } else -#endif if( !BDB_IDL_IS_RANGE(candidates) ) { /* only complain for non-range IDLs */ Debug( LDAP_DEBUG_TRACE, @@ -1319,11 +694,6 @@ fetch_entry_retry: goto loop_continue; } -#ifdef BDB_PSEARCH - } else { - e = ps_e; - } -#endif rs->sr_entry = e; @@ -1422,11 +792,7 @@ fetch_entry_retry: } /* Not in scope, ignore it */ -#ifdef BDB_PSEARCH - if ( !IS_POST_SEARCH && !scopeok ) -#else if ( !scopeok ) -#endif { Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_search) @@ -1462,72 +828,16 @@ fetch_entry_retry: } /* if it matches the filter and scope, send it */ -#ifndef BDB_PSEARCH rs->sr_err = test_filter( sop, rs->sr_entry, sop->oq_search.rs_filter ); -#else - if (IS_PSEARCH) { - if (ps_type != LDAP_PSEARCH_BY_SCOPEOUT) { - rs->sr_err = test_filter( sop, rs->sr_entry, &cookief ); - } else { - rs->sr_err = LDAP_COMPARE_TRUE; - } - - } else { - if ( !IS_POST_SEARCH ) { - if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) { - rc_sync = test_filter( sop, rs->sr_entry, &cookief ); - rs->sr_err = test_filter( sop, rs->sr_entry, - &contextcsnand ); - if ( rs->sr_err == LDAP_COMPARE_TRUE ) { - if ( rc_sync == LDAP_COMPARE_TRUE ) { - if ( no_sync_state_change ) { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_search) ": " - "error in context csn management\n", - 0, 0, 0 ); - } - entry_sync_state = LDAP_SYNC_ADD; - - } else { - if ( no_sync_state_change ) { - goto loop_continue; - } - entry_sync_state = LDAP_SYNC_PRESENT; - } - } - } else { - rs->sr_err = test_filter( sop, - rs->sr_entry, sop->oq_search.rs_filter ); - } - } else { - if ( scopeok ) { - rs->sr_err = test_filter( sop, - rs->sr_entry, sop->oq_search.rs_filter ); - } else { - rs->sr_err = LDAP_COMPARE_TRUE; - } - } - } -#endif if ( rs->sr_err == LDAP_COMPARE_TRUE ) { /* check size limit */ - if ( --sop->ors_slimit == -1 -#ifdef BDB_PSEARCH - && sop->o_sync_slog_size == -1 -#endif - ) { -#ifdef BDB_PSEARCH - if (!IS_PSEARCH) { -#endif + if ( --sop->ors_slimit == -1) { #ifdef SLAP_ZONE_ALLOC - slap_zn_runlock(bdb->bi_cache.c_zctx, e); + slap_zn_runlock(bdb->bi_cache.c_zctx, e); #endif - bdb_cache_return_entry_r( bdb->bi_dbenv, + bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock ); -#ifdef BDB_PSEARCH - } -#endif e = NULL; rs->sr_entry = NULL; rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; @@ -1548,170 +858,12 @@ fetch_entry_retry: if (e) { /* safe default */ int result = -1; -#ifdef BDB_PSEARCH - if (IS_PSEARCH || IS_POST_SEARCH) { - int premodify_found = 0; - - if ( IS_POST_SEARCH || - ps_type == LDAP_PSEARCH_BY_ADD || - ps_type == LDAP_PSEARCH_BY_DELETE || - ps_type == LDAP_PSEARCH_BY_MODIFY || - ps_type == LDAP_PSEARCH_BY_SCOPEOUT ) - { - if ( !IS_POST_SEARCH && - ps_type == LDAP_PSEARCH_BY_MODIFY ) { - struct psid_entry* psid_e; - LDAP_LIST_FOREACH( psid_e, - &op->o_pm_list, ps_link) - { - if( psid_e->ps_op == sop ) { - premodify_found = 1; - LDAP_LIST_REMOVE(psid_e, ps_link); - break; - } - } - if (psid_e != NULL) free (psid_e); - } - - if ( IS_POST_SEARCH ) { - if ( scopeok ) { - entry_sync_state = LDAP_SYNC_ADD; - } else { -post_search_no_entry: - entry_sync_state = LDAP_SYNC_DELETE; - } - } else if ( ps_type == LDAP_PSEARCH_BY_ADD ) { - entry_sync_state = LDAP_SYNC_ADD; - } else if ( ps_type == LDAP_PSEARCH_BY_DELETE ) { - entry_sync_state = LDAP_SYNC_DELETE; - } else if ( ps_type == LDAP_PSEARCH_BY_MODIFY ) { - if ( premodify_found ) { - entry_sync_state = LDAP_SYNC_MODIFY; - } else { - entry_sync_state = LDAP_SYNC_ADD; - } - } else if ( ps_type == LDAP_PSEARCH_BY_SCOPEOUT ) { - entry_sync_state = LDAP_SYNC_DELETE; - } else { - rs->sr_err = LDAP_OTHER; - goto done; - } - - if ( sop->o_sync_slog_size != -1 ) { - if ( entry_sync_state == LDAP_SYNC_DELETE ) { - result = slap_add_session_log( op, sop, e ); - } else { - result = 1; - } - } else { - struct berval cookie; - slap_compose_sync_cookie( sop, &cookie, - search_context_csn, - sop->o_sync_state.sid, - sop->o_sync_state.rid ); - rs->sr_err = slap_build_sync_state_ctrl( - sop, rs, e, entry_sync_state, ctrls, - num_ctrls++, 1, &cookie ); - if ( rs->sr_err != LDAP_SUCCESS ) goto done; - if (!(IS_POST_SEARCH && - entry_sync_state == LDAP_SYNC_DELETE)) { - rs->sr_attrs = attrs; - } else { - rs->sr_attrs = NULL; - } - rs->sr_operational_attrs = NULL; - rs->sr_ctrls = ctrls; - rs->sr_flags = 0; - result = send_search_entry( sop, rs ); - if ( cookie.bv_val ) ch_free( cookie.bv_val ); - slap_sl_free( - ctrls[num_ctrls-1]->ldctl_value.bv_val, - sop->o_tmpmemctx ); - slap_sl_free( ctrls[--num_ctrls], - sop->o_tmpmemctx ); - ctrls[num_ctrls] = NULL; - rs->sr_ctrls = NULL; - } - - } else if ( ps_type == LDAP_PSEARCH_BY_PREMODIFY ) { - struct psid_entry* psid_e; - psid_e = (struct psid_entry *) ch_calloc(1, - sizeof(struct psid_entry)); - psid_e->ps_op = sop; - LDAP_LIST_INSERT_HEAD( &op->o_pm_list, - psid_e, ps_link ); - - } else { - Debug( LDAP_DEBUG_TRACE, - LDAP_XSTRING(bdb_search) - ": invalid ps_type (%d) \n", - ps_type, 0, 0); - } - - } else { - if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) { - if ( rc_sync == LDAP_COMPARE_TRUE ) { /* ADD */ - rs->sr_err = slap_build_sync_state_ctrl( - sop, rs, e, entry_sync_state, ctrls, - num_ctrls++, 0, NULL ); - if ( rs->sr_err != LDAP_SUCCESS ) goto done; - rs->sr_ctrls = ctrls; - rs->sr_attrs = sop->oq_search.rs_attrs; - rs->sr_operational_attrs = NULL; - rs->sr_flags = 0; - result = send_search_entry( sop, rs ); - slap_sl_free( - ctrls[num_ctrls-1]->ldctl_value.bv_val, - sop->o_tmpmemctx ); - slap_sl_free( ctrls[--num_ctrls], - sop->o_tmpmemctx ); - ctrls[num_ctrls] = NULL; - rs->sr_ctrls = NULL; - - } else { /* PRESENT */ - if ( sync_send_present_mode ) { - result = slap_build_syncUUID_set( sop, - &syncUUID_set, e ); - if ( result <= 0 ) { - result = -1; - } else { - syncUUID_set_cnt++; - if ( syncUUID_set_cnt == - SLAP_SYNCUUID_SET_SIZE ) - { - rs->sr_err = LDAP_SUCCESS; - rs->sr_rspoid = LDAP_SYNC_INFO; - rs->sr_ctrls = NULL; - result = slap_send_syncinfo( sop, rs, - LDAP_TAG_SYNC_ID_SET, - NULL, 0, syncUUID_set, 0 ); - if ( result != LDAP_SUCCESS ) { - result = -1; - } - ber_bvarray_free_x( syncUUID_set, - sop->o_tmpmemctx ); - syncUUID_set = NULL; - syncUUID_set_cnt = 0; - } - } - - } else { - result = 1; - } - } - - } else { -#endif - rs->sr_attrs = sop->oq_search.rs_attrs; - rs->sr_operational_attrs = NULL; - rs->sr_ctrls = NULL; - rs->sr_flags = 0; - rs->sr_err = LDAP_SUCCESS; - result = send_search_entry( sop, rs ); -#ifdef BDB_PSEARCH - } - } -#endif + rs->sr_attrs = sop->oq_search.rs_attrs; + rs->sr_operational_attrs = NULL; + rs->sr_ctrls = NULL; + rs->sr_flags = 0; + rs->sr_err = LDAP_SUCCESS; + result = send_search_entry( sop, rs ); switch (result) { case 0: /* entry sent ok */ @@ -1719,17 +871,11 @@ post_search_no_entry: case 1: /* entry not sent */ break; case -1: /* connection closed */ -#ifdef BDB_PSEARCH - if (!IS_PSEARCH) { -#endif #ifdef SLAP_ZONE_ALLOC - slap_zn_runlock(bdb->bi_cache.c_zctx, e); -#endif - bdb_cache_return_entry_r(bdb->bi_dbenv, - &bdb->bi_cache, e, &lock); -#ifdef BDB_PSEARCH - } + slap_zn_runlock(bdb->bi_cache.c_zctx, e); #endif + bdb_cache_return_entry_r(bdb->bi_dbenv, + &bdb->bi_cache, e, &lock); e = NULL; rs->sr_entry = NULL; rs->sr_err = LDAP_OTHER; @@ -1747,194 +893,32 @@ post_search_no_entry: loop_continue: if( e != NULL ) { /* free reader lock */ -#ifdef BDB_PSEARCH - if (!IS_PSEARCH) { - if (!(IS_POST_SEARCH && - entry_sync_state == LDAP_SYNC_DELETE)) { -#ifdef SLAP_ZONE_ALLOC - slap_zn_runlock(bdb->bi_cache.c_zctx, e); -#endif - bdb_cache_return_entry_r( bdb->bi_dbenv, - &bdb->bi_cache, e , &lock ); - if ( sop->o_nocaching ) { - bdb_cache_delete_entry( bdb, ei, locker, &lock ); - } - } - } -#else #ifdef SLAP_ZONE_ALLOC slap_zn_runlock(bdb->bi_cache.c_zctx, e); #endif bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e , &lock ); -#endif e = NULL; rs->sr_entry = NULL; } -#ifdef BDB_PSEARCH - if ( sop->o_refresh_in_progress ) { - if ( pce ) { - pce->pc_sent = 1; - } - } -#endif - ldap_pvt_thread_yield(); } -#ifdef BDB_PSEARCH - if ( syncUUID_set_cnt > 0 ) { - rs->sr_err = LDAP_SUCCESS; - rs->sr_rspoid = LDAP_SYNC_INFO; - rs->sr_ctrls = NULL; - slap_send_syncinfo( sop, rs, LDAP_TAG_SYNC_ID_SET, - NULL, 0, syncUUID_set, 0 ); - ber_bvarray_free_x( syncUUID_set, sop->o_tmpmemctx ); - syncUUID_set_cnt = 0; - } -#endif - nochange: -#ifdef BDB_PSEARCH - if (!IS_PSEARCH && !IS_POST_SEARCH) { - if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) { - if ( sop->o_sync_mode & SLAP_SYNC_PERSIST ) { - struct berval cookie; - slap_compose_sync_cookie( sop, &cookie, search_context_csn, - sop->o_sync_state.sid, sop->o_sync_state.rid ); - - if ( sync_send_present_mode ) { - rs->sr_err = LDAP_SUCCESS; - rs->sr_rspoid = LDAP_SYNC_INFO; - rs->sr_ctrls = NULL; - slap_send_syncinfo( sop, rs, - LDAP_TAG_SYNC_REFRESH_PRESENT, &cookie, 1, NULL, 0 ); - - } else { - if ( !no_sync_state_change ) { - int slog_found = 0; - ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock ); - LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, - o_ps_link ) - { - if ( ps_list->o_sync_slog_size > 0 ) { - if ( ps_list->o_sync_state.sid == - sop->o_sync_state.sid ) - { - slog_found = 1; - break; - } - } - } - - if ( slog_found ) { - rs->sr_err = LDAP_SUCCESS; - rs->sr_rspoid = NULL; - rs->sr_ctrls = NULL; - slap_send_session_log( op, ps_list, rs ); - } - ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock ); - } - - rs->sr_err = LDAP_SUCCESS; - rs->sr_rspoid = LDAP_SYNC_INFO; - rs->sr_ctrls = NULL; - slap_send_syncinfo( sop, rs, - LDAP_TAG_SYNC_REFRESH_DELETE, &cookie, 1, NULL, 0 ); - } - - if ( cookie.bv_val ) ch_free( cookie.bv_val ); - - } else { - /* refreshOnly mode */ - struct berval cookie; - slap_compose_sync_cookie( sop, &cookie, search_context_csn, - sop->o_sync_state.sid, sop->o_sync_state.rid ); - - if ( sync_send_present_mode ) { - slap_build_sync_done_ctrl( sop, rs, ctrls, - num_ctrls++, 1, &cookie, LDAP_SYNC_REFRESH_PRESENTS ); - - } else { - if ( !no_sync_state_change ) { - int slog_found = 0; - ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock ); - LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, - o_ps_link ) - { - if ( ps_list->o_sync_slog_size > 0 ) { - if ( ps_list->o_sync_state.sid == - sop->o_sync_state.sid ) { - slog_found = 1; - break; - } - } - } - - if ( slog_found ) { - slap_send_session_log( op, ps_list, rs ); - } - ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock ); - } - - slap_build_sync_done_ctrl( sop, rs, ctrls, - num_ctrls++, 1, &cookie, LDAP_SYNC_REFRESH_DELETES ); - } - - rs->sr_ctrls = ctrls; - rs->sr_ref = rs->sr_v2ref; - rs->sr_err = (rs->sr_v2ref == NULL) - ? LDAP_SUCCESS : LDAP_REFERRAL; - rs->sr_rspoid = NULL; - send_ldap_result( sop, rs ); - if ( ctrls[num_ctrls-1]->ldctl_value.bv_val != NULL ) { - slap_sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val, - sop->o_tmpmemctx ); - } - slap_sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx ); - ctrls[num_ctrls] = NULL; - if ( cookie.bv_val ) ch_free( cookie.bv_val ); - } - - } else { -#endif - rs->sr_ctrls = NULL; - rs->sr_ref = rs->sr_v2ref; - rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL; - rs->sr_rspoid = NULL; - if ( get_pagedresults(sop) > SLAP_CONTROL_IGNORED ) { - send_paged_response( sop, rs, NULL, 0 ); - } else { - send_ldap_result( sop, rs ); - } -#ifdef BDB_PSEARCH - } - } - - if ( sop->o_refresh_in_progress ) { - sop->o_refresh_in_progress = 0; + rs->sr_ctrls = NULL; + rs->sr_ref = rs->sr_v2ref; + rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL; + rs->sr_rspoid = NULL; + if ( get_pagedresults(sop) > SLAP_CONTROL_IGNORED ) { + send_paged_response( sop, rs, NULL, 0 ); + } else { + send_ldap_result( sop, rs ); } -#endif rs->sr_err = LDAP_SUCCESS; done: -#ifdef BDB_PSEARCH - if ( sop->o_psearch_finished ) { - avl_free( sop->o_psearch_finished, ch_free ); - } - - if( !IS_PSEARCH && e != NULL ) { - /* free reader lock */ -#ifdef SLAP_ZONE_ALLOC - slap_zn_runlock(bdb->bi_cache.c_zctx, e); -#endif - bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock ); - } - ber_bvfree( search_context_csn ); -#endif - if ( !opinfo ) LOCK_ID_FREE( bdb->bi_dbenv, locker ); @@ -2064,11 +1048,7 @@ static int search_candidates( * these clauses are redundant. */ if (!oc_filter(op->oq_search.rs_filter, 1, &depth) - && !get_subentries_visibility(op) -#ifdef BDB_PSEARCH - && !is_sync_protocol(op) -#endif - ) { + && !get_subentries_visibility(op)) { if( !get_manageDSAit(op) && !get_domainScope(op) ) { /* match referral objects */ struct berval bv_ref = BER_BVC( "referral" ); diff --git a/servers/slapd/back-hdb/Makefile.in b/servers/slapd/back-hdb/Makefile.in index 8dc0405bf2..e7fa1e7ec3 100644 --- a/servers/slapd/back-hdb/Makefile.in +++ b/servers/slapd/back-hdb/Makefile.in @@ -21,13 +21,13 @@ XXSRCS = init.c tools.c config.c \ add.c bind.c compare.c delete.c modify.c modrdn.c search.c \ extended.c referral.c operational.c \ attr.c index.c key.c dbcache.c filterindex.c trans.c \ - dn2entry.c dn2id.c error.c id2entry.c idl.c nextid.c cache.c ctxcsn.c + dn2entry.c dn2id.c error.c id2entry.c idl.c nextid.c cache.c SRCS = $(XXSRCS) OBJS = init.lo tools.lo config.lo \ add.lo bind.lo compare.lo delete.lo modify.lo modrdn.lo search.lo \ extended.lo referral.lo operational.lo \ attr.lo index.lo key.lo dbcache.lo filterindex.lo trans.lo \ - dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo cache.lo ctxcsn.lo + dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo cache.lo LDAP_INCDIR= ../../../include LDAP_LIBDIR= ../../../libraries -- 2.39.5