From f845c573b08fca473326639d2b8cad24b3f7f22f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 13 Jan 2005 21:15:50 +0000 Subject: [PATCH] Single consumer context per database --- servers/slapd/back-bdb/delete.c | 6 +++--- servers/slapd/back-bdb/modify.c | 6 +++--- servers/slapd/back-bdb/modrdn.c | 6 +++--- servers/slapd/back-ldbm/delete.c | 6 +++--- servers/slapd/back-ldbm/modify.c | 6 +++--- servers/slapd/back-ldbm/modrdn.c | 6 +++--- servers/slapd/backend.c | 14 +++++--------- servers/slapd/config.c | 15 ++------------- servers/slapd/frontend.c | 2 -- servers/slapd/slap.h | 3 +-- servers/slapd/syncrepl.c | 2 -- 11 files changed, 26 insertions(+), 46 deletions(-) diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 584fce898a..8937180724 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -163,9 +163,9 @@ retry: /* transaction retry */ matched = NULL; } else { - if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - syncinfo_t *si; - LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) { + if ( op->o_bd->be_syncinfo ) { + syncinfo_t *si = op->o_bd->be_syncinfo; + { struct berval tmpbv; ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] ); ber_bvarray_add( &deref, &tmpbv ); diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 109b41a6b3..4ad218ac14 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -392,9 +392,9 @@ retry: /* transaction retry */ e = NULL; } else { - if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - syncinfo_t *si; - LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) { + if ( op->o_bd->be_syncinfo ) { + syncinfo_t *si = op->o_bd->be_syncinfo; + { struct berval tmpbv; ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] ); ber_bvarray_add( &deref, &tmpbv ); diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index a08e7f8d16..b7ebd0bbff 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -182,9 +182,9 @@ retry: /* transaction retry */ e = NULL; } else { - if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - syncinfo_t *si; - LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) { + if ( op->o_bd->be_syncinfo ) { + syncinfo_t *si = op->o_bd->be_syncinfo; + { struct berval tmpbv; ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] ); ber_bvarray_add( &deref, &tmpbv ); diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 01ae6c7275..88e5493575 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -62,9 +62,9 @@ ldbm_back_delete( cache_return_entry_r( &li->li_cache, matched ); } else { - if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - syncinfo_t *si; - LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) { + if ( op->o_bd->be_syncinfo ) { + syncinfo_t *si = op->o_bd->be_syncinfo; + { struct berval tmpbv; ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] ); ber_bvarray_add( &deref, &tmpbv ); diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 21e4bdb74c..725298b78d 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -257,9 +257,9 @@ ldbm_back_modify( : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { - if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - syncinfo_t *si; - LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) { + if ( op->o_bd->be_syncinfo ) { + syncinfo_t *si = op->o_bd->be_syncinfo; + { struct berval tmpbv; ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] ); ber_bvarray_add( &deref, &tmpbv ); diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index d2cdf89816..02039d4c9f 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -85,9 +85,9 @@ ldbm_back_modrdn( : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { - if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - syncinfo_t *si; - LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) { + if ( op->o_bd->be_syncinfo ) { + syncinfo_t *si = op->o_bd->be_syncinfo; + { struct berval tmpbv; ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] ); ber_bvarray_add( &deref, &tmpbv ); diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 91dc769818..13dd961342 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -266,7 +266,7 @@ int backend_startup(Backend *be) if ( rc ) return rc; - if ( !LDAP_STAILQ_EMPTY( &backendDB[i].be_syncinfo )) { + if ( backendDB[i].be_syncinfo ) { syncinfo_t *si; if ( !( backendDB[i].be_search && backendDB[i].be_add && @@ -277,7 +277,8 @@ int backend_startup(Backend *be) continue; } - LDAP_STAILQ_FOREACH( si, &backendDB[i].be_syncinfo, si_next ) { + { + si = backendDB[i].be_syncinfo; si->si_be = &backendDB[i]; init_syncrepl( si ); ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); @@ -371,7 +372,6 @@ int backend_destroy(void) { int i; BackendDB *bd; - syncinfo_t *si_entry; struct slap_csn_entry *csne; ldap_pvt_thread_pool_destroy( &syncrepl_pool, 1 ); @@ -379,10 +379,8 @@ int backend_destroy(void) /* destroy each backend database */ for( i = 0, bd = backendDB; i < nBackendDB; i++, bd++ ) { - while ( !LDAP_STAILQ_EMPTY( &bd->be_syncinfo )) { - si_entry = LDAP_STAILQ_FIRST( &bd->be_syncinfo ); - LDAP_STAILQ_REMOVE_HEAD( &bd->be_syncinfo, si_next ); - syncinfo_free( si_entry ); + if ( bd->be_syncinfo ) { + syncinfo_free( bd->be_syncinfo ); } if ( bd->be_pending_csn_list ) { @@ -500,8 +498,6 @@ backend_db_init( be->be_pcl_mutexp = &be->be_pcl_mutex; ldap_pvt_thread_mutex_init( be->be_pcl_mutexp ); - LDAP_STAILQ_INIT( &be->be_syncinfo ); - /* assign a default depth limit for alias deref */ be->be_max_deref_depth = SLAPD_DEFAULT_MAXDEREFDEPTH; diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 6a91564813..72e8ef8c40 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -1637,9 +1637,7 @@ add_syncrepl( ) { syncinfo_t *si; - syncinfo_t *si_entry; int rc = 0; - int duplicated_replica_id = 0; si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) ); @@ -1678,16 +1676,7 @@ add_syncrepl( rc = parse_syncrepl_line( cargv, cargc, si ); - LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) { - if ( si->si_rid == si_entry->si_rid ) { - Debug( LDAP_DEBUG_ANY, - "add_syncrepl: duplicated replica id\n",0, 0, 0 ); - duplicated_replica_id = 1; - break; - } - } - - if ( rc < 0 || duplicated_replica_id ) { + if ( rc < 0 ) { Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 ); syncinfo_free( si ); return 1; @@ -1699,7 +1688,7 @@ add_syncrepl( SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK; } si->si_be = be; - LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next ); + be->be_syncinfo = si; return 0; } } diff --git a/servers/slapd/frontend.c b/servers/slapd/frontend.c index 3ab670dcae..e1fca24d32 100644 --- a/servers/slapd/frontend.c +++ b/servers/slapd/frontend.c @@ -69,8 +69,6 @@ frontend_init( void ) /* FIXME: do we need this? */ frontendDB->be_pcl_mutexp = &frontendDB->be_pcl_mutex; ldap_pvt_thread_mutex_init( frontendDB->be_pcl_mutexp ); - - LDAP_STAILQ_INIT( &frontendDB->be_syncinfo ); #endif /* suffix */ diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 380ee9a53e..92dc8f2ef9 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1514,7 +1514,6 @@ typedef struct syncinfo_s { Avlnode *si_presentlist; LDAP *si_ld; LDAP_LIST_HEAD(np, nonpresent_entry) si_nonpresentlist; - LDAP_STAILQ_ENTRY( syncinfo_s ) si_next; } syncinfo_t; LDAP_TAILQ_HEAD( be_pcl, slap_csn_entry ); @@ -1678,7 +1677,7 @@ struct slap_backend_db { struct be_pcl *be_pending_csn_list; ldap_pvt_thread_mutex_t be_pcl_mutex; ldap_pvt_thread_mutex_t *be_pcl_mutexp; - LDAP_STAILQ_HEAD( be_si, syncinfo_s ) be_syncinfo; /* For syncrepl */ + syncinfo_t *be_syncinfo; /* For syncrepl */ char *be_realm; void *be_pb; /* Netscape plugin */ diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 50b1dc49f3..271399f654 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -998,8 +998,6 @@ do_syncrepl( if ( !si->si_retrynum || si->si_retrynum[i] == -2 ) { ldap_pvt_runqueue_remove( &slapd_rq, rtask ); - LDAP_STAILQ_REMOVE( &be->be_syncinfo, si, syncinfo_s, si_next ); - syncinfo_free( si ); } else if ( si->si_retrynum[i] >= -1 ) { if ( si->si_retrynum[i] > 0 ) si->si_retrynum[i]--; -- 2.39.5