From: Howard Chu Date: Wed, 2 Apr 2008 03:08:06 +0000 (+0000) Subject: ITS#5442 slapd_rq mutexes must always be used X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~46 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f2de258e3da0da9137ca8b9cead427c5cd98b859;p=openldap ITS#5442 slapd_rq mutexes must always be used --- diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index 184ebb64d5..08ac6468a6 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -483,9 +483,11 @@ bdb_cf_gen( ConfigArgs *c ) if ( bdb->bi_txn_cp_task ) { struct re_s *re = bdb->bi_txn_cp_task; bdb->bi_txn_cp_task = NULL; + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ) ) ldap_pvt_runqueue_stoptask( &slapd_rq, re ); ldap_pvt_runqueue_remove( &slapd_rq, re ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); } bdb->bi_txn_cp = 0; break; @@ -620,9 +622,11 @@ bdb_cf_gen( ConfigArgs *c ) c->log ); return 1; } + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); bdb->bi_txn_cp_task = ldap_pvt_runqueue_insert( &slapd_rq, bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb, LDAP_XSTRING(bdb_checkpoint), c->be->be_suffix[0].bv_val ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); } } } break; @@ -747,9 +751,11 @@ bdb_cf_gen( ConfigArgs *c ) c->log ); return 1; } + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); bdb->bi_index_task = ldap_pvt_runqueue_insert( &slapd_rq, 36000, bdb_online_index, c->be, LDAP_XSTRING(bdb_online_index), c->be->be_suffix[0].bv_val ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); } break; diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c index d63b427229..c77732a729 100644 --- a/servers/slapd/overlays/accesslog.c +++ b/servers/slapd/overlays/accesslog.c @@ -769,9 +769,11 @@ log_cf_gen(ConfigArgs *c) if ( li->li_task ) { struct re_s *re = li->li_task; li->li_task = NULL; + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re )) ldap_pvt_runqueue_stoptask( &slapd_rq, re ); ldap_pvt_runqueue_remove( &slapd_rq, re ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); } li->li_age = 0; li->li_cycle = 0; @@ -843,12 +845,15 @@ log_cf_gen(ConfigArgs *c) struct re_s *re = li->li_task; if ( re ) re->interval.tv_sec = li->li_cycle; - else + else { + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); li->li_task = ldap_pvt_runqueue_insert( &slapd_rq, li->li_cycle, accesslog_purge, li, "accesslog_purge", li->li_db ? li->li_db->be_suffix[0].bv_val : c->be->be_suffix[0].bv_val ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); + } } } break; @@ -2022,8 +2027,10 @@ accesslog_db_open( ber_dupbv( &li->li_db->be_rootndn, li->li_db->be_nsuffix ); } + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); ldap_pvt_runqueue_insert( &slapd_rq, 3600, accesslog_db_root, on, "accesslog_db_root", li->li_db->be_suffix[0].bv_val ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); return 0; } diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index e8ddee979a..a3444b5c07 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -3260,6 +3260,7 @@ syncinfo_free( syncinfo_t *sie, int free_all ) } /* re-fetch it, in case it was already removed */ + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); sie->si_re = ldap_pvt_runqueue_find( &slapd_rq, do_syncrepl, sie ); if ( sie->si_re ) { if ( ldap_pvt_runqueue_isrunning( &slapd_rq, sie->si_re ) ) @@ -3267,6 +3268,7 @@ syncinfo_free( syncinfo_t *sie, int free_all ) ldap_pvt_runqueue_remove( &slapd_rq, sie->si_re ); } + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); ldap_pvt_thread_mutex_destroy( &sie->si_mutex ); bindconf_free( &sie->si_bindconf ); @@ -3917,9 +3919,11 @@ add_syncrepl( if ( !isMe ) { init_syncrepl( si ); + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); si->si_re = ldap_pvt_runqueue_insert( &slapd_rq, si->si_interval, do_syncrepl, si, "do_syncrepl", si->si_ridtxt ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); if ( si->si_re ) rc = config_sync_shadow( c ) ? -1 : 0; else @@ -4148,13 +4152,18 @@ syncrepl_config( ConfigArgs *c ) for ( sip = &c->be->be_syncinfo, i=0; *sip; i++ ) { si = *sip; if ( c->valx == -1 || i == c->valx ) { + int isrunning = 0; *sip = si->si_next; /* If the task is currently active, we have to leave * it running. It will exit on its own. This will only * happen when running on the cn=config DB. */ - if ( si->si_re && - ldap_pvt_runqueue_isrunning( &slapd_rq, si->si_re ) ) { + if ( si->si_re ) { + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); + isrunning = ldap_pvt_runqueue_isrunning( &slapd_rq, si->si_re ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); + } + if ( si->si_re && isrunning ) { si->si_ctype = 0; } else { syncinfo_free( si, 0 );