From: Howard Chu Date: Fri, 3 Dec 2004 16:49:23 +0000 (+0000) Subject: Rename syncrepl_rq to slapd_rq, move to daemon.c X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~145 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5c8fd8bf11030c783aedf2bb86a51edd31a954a9;p=openldap Rename syncrepl_rq to slapd_rq, move to daemon.c --- diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index fb8fc0fe1b..2b7f3eee54 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -261,9 +261,9 @@ int backend_startup(Backend *be) } } - ldap_pvt_thread_mutex_init( &syncrepl_rq.rq_mutex ); - LDAP_STAILQ_INIT( &syncrepl_rq.task_list ); - LDAP_STAILQ_INIT( &syncrepl_rq.run_list ); + ldap_pvt_thread_mutex_init( &slapd_rq.rq_mutex ); + LDAP_STAILQ_INIT( &slapd_rq.task_list ); + LDAP_STAILQ_INIT( &slapd_rq.run_list ); /* open each backend database */ for( i = 0; i < nBackendDB; i++ ) { @@ -295,10 +295,10 @@ int backend_startup(Backend *be) LDAP_STAILQ_FOREACH( si, &backendDB[i].be_syncinfo, si_next ) { si->si_be = &backendDB[i]; init_syncrepl( si ); - ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); - ldap_pvt_runqueue_insert( &syncrepl_rq, + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); + ldap_pvt_runqueue_insert( &slapd_rq, si->si_interval, do_syncrepl, (void *) si ); - ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); } } } diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 206c401777..a4e3124ed9 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -72,6 +72,7 @@ int slap_inet4or6 = AF_INET; time_t starttime; ber_socket_t dtblsize; slap_ssf_t local_ssf = LDAP_PVT_SASL_LOCAL_SSF; +struct runqueue_s slapd_rq; Listener **slap_listeners = NULL; @@ -1648,22 +1649,22 @@ slapd_daemon_task( else tvp = NULL; - ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); - rtask = ldap_pvt_runqueue_next_sched( &syncrepl_rq, &cat ); + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); + rtask = ldap_pvt_runqueue_next_sched( &slapd_rq, &cat ); while ( cat && cat->tv_sec && cat->tv_sec <= now ) { - if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) { - ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, 0 ); + if ( ldap_pvt_runqueue_isrunning( &slapd_rq, rtask )) { + ldap_pvt_runqueue_resched( &slapd_rq, rtask, 0 ); } else { - ldap_pvt_runqueue_runtask( &syncrepl_rq, rtask ); - ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, 0 ); - ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); + ldap_pvt_runqueue_runtask( &slapd_rq, rtask ); + ldap_pvt_runqueue_resched( &slapd_rq, rtask, 0 ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); ldap_pvt_thread_pool_submit( &connection_pool, rtask->routine, (void *) rtask ); - ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); } - rtask = ldap_pvt_runqueue_next_sched( &syncrepl_rq, &cat ); + rtask = ldap_pvt_runqueue_next_sched( &slapd_rq, &cat ); } - ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); if ( cat != NULL ) { time_t diff = difftime( cat->tv_sec, now ); diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 150dca2ad9..35a344ef3a 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -1123,12 +1123,12 @@ proxy_cache_response( * wake it back up */ if ( cm->cc_paused ) { - ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); if ( cm->cc_paused ) { cm->cc_paused = 0; - ldap_pvt_runqueue_resched( &syncrepl_rq, cm->cc_arg, 0 ); + ldap_pvt_runqueue_resched( &slapd_rq, cm->cc_arg, 0 ); } - ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); } } @@ -1466,15 +1466,15 @@ consistency_check( } ldap_pvt_thread_mutex_unlock(&cm->remove_mutex); } - ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); - if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) { - ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask ); + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); + if ( ldap_pvt_runqueue_isrunning( &slapd_rq, rtask )) { + ldap_pvt_runqueue_stoptask( &slapd_rq, rtask ); } /* If there were no queries, defer processing for a while */ cm->cc_paused = pause; - ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, pause ); + ldap_pvt_runqueue_resched( &slapd_rq, rtask, pause ); - ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); return NULL; } @@ -1738,10 +1738,10 @@ proxy_cache_open( /* There is no runqueue in TOOL mode */ if ( slapMode & SLAP_SERVER_MODE ) { - ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); - ldap_pvt_runqueue_insert( &syncrepl_rq, cm->cc_period, + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); + ldap_pvt_runqueue_insert( &slapd_rq, cm->cc_period, consistency_check, on ); - ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); /* Cached database must have the rootdn */ if ( BER_BVISNULL( &cm->db.be_rootndn ) diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 06a6d469cd..bfcafdc105 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -513,6 +513,7 @@ LDAP_SLAPD_V (volatile sig_atomic_t) slapd_abrupt_shutdown; LDAP_SLAPD_V (volatile sig_atomic_t) slapd_shutdown; LDAP_SLAPD_V (int) slapd_register_slp; LDAP_SLAPD_V (slap_ssf_t) local_ssf; +LDAP_SLAPD_V (struct runqueue_s) slapd_rq; /* * dn.c @@ -1246,8 +1247,6 @@ LDAP_SLAPD_F (Filter *) str2filter_x LDAP_P(( Operation *op, const char *str )); * syncrepl.c */ -LDAP_SLAPD_V (struct runqueue_s) syncrepl_rq; - LDAP_SLAPD_F (void) init_syncrepl LDAP_P((syncinfo_t *)); LDAP_SLAPD_F (void*) do_syncrepl LDAP_P((void *, void *)); LDAP_SLAPD_F (int) syncrepl_message_to_entry LDAP_P(( diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 61abe66192..9524e27410 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -50,8 +50,6 @@ static int null_callback( struct slap_op *, struct slap_rep * ); static AttributeDescription *sync_descs[4]; -struct runqueue_s syncrepl_rq; - void init_syncrepl(syncinfo_t *si) { @@ -969,10 +967,10 @@ do_syncrepl( * 3) for Refresh and Success, reschedule to run * 4) for Persist and Success, reschedule to defer */ - ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); - if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) { - ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask ); + if ( ldap_pvt_runqueue_isrunning( &slapd_rq, rtask )) { + ldap_pvt_runqueue_stoptask( &slapd_rq, rtask ); } if ( dostop ) { @@ -984,7 +982,7 @@ do_syncrepl( defer = 0; } rtask->interval.tv_sec = si->si_interval; - ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, defer ); + ldap_pvt_runqueue_resched( &slapd_rq, rtask, defer ); if ( si->si_retrynum ) { for ( i = 0; si->si_retrynum_init[i] != -2; i++ ) { si->si_retrynum[i] = si->si_retrynum_init[i]; @@ -998,19 +996,19 @@ do_syncrepl( } if ( !si->si_retrynum || si->si_retrynum[i] == -2 ) { - ldap_pvt_runqueue_remove( &syncrepl_rq, rtask ); + 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]--; rtask->interval.tv_sec = si->si_retryinterval[i]; - ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, 0 ); + ldap_pvt_runqueue_resched( &slapd_rq, rtask, 0 ); slap_wake_listener(); } } - ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); return NULL; }