X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fsyncrepl.c;h=07e9dd78577fb08c33b472ac2a67a339204a7b06;hb=861441fcf7661e6a13dfe236537dd318a58492d1;hp=6282013598b927df02897dadb30d78c02d3e89de;hpb=79024465dc795538f80160badbc5bbe32ff6e3b7;p=openldap diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 6282013598..07e9dd7857 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -1256,7 +1256,7 @@ do_syncrepl( int rc = LDAP_SUCCESS; int dostop = 0; ber_socket_t s; - int i, defer = 1, fail = 0; + int i, defer = 1, fail = 0, freeinfo = 0; Backend *be; if ( si == NULL ) @@ -1274,8 +1274,9 @@ do_syncrepl( ldap_pvt_thread_yield(); } - if ( !si->si_ctype ) + if ( si->si_ctype < 1 ) { goto deleted; + } switch( abs( si->si_type ) ) { case LDAP_SYNC_REFRESH_ONLY: @@ -1362,7 +1363,11 @@ reload: deleted: /* We got deleted while running on cn=config */ - if ( !si->si_ctype ) { + if ( si->si_ctype < 1 ) { + if ( si->si_ctype == -1 ) { + si->si_ctype = 0; + freeinfo = 1; + } if ( si->si_conn ) dostop = 1; rc = -1; @@ -1429,7 +1434,7 @@ deleted: break; } - if ( !si->si_ctype + if ( si->si_ctype < 1 || !si->si_retrynum || si->si_retrynum[i] == RETRYNUM_TAIL ) { if ( si->si_re ) { ldap_pvt_runqueue_remove( &slapd_rq, rtask ); @@ -1466,7 +1471,7 @@ deleted: } /* Do final delete cleanup */ - if ( !si->si_ctype ) { + if ( freeinfo ) { syncinfo_free( si, 0 ); } return NULL; @@ -4626,27 +4631,19 @@ syncrepl_config( ConfigArgs *c ) isrunning = 1; } else { if ( si->si_conn ) { - isrunning = 1; - /* If there's a persistent connection, we don't - * know if it's already got a thread queued. - * so defer the free, but reschedule the task. - * If there's a connection thread queued, it - * will cleanup as necessary. If not, then the - * runqueue task will cleanup. + /* If there's a persistent connection, it may + * already have a thread queued. We know it's + * not active, so it must be pending and we + * can simply cancel it now. */ - ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); - if ( !ldap_pvt_runqueue_isrunning( &slapd_rq, si->si_re )) { - si->si_re->interval.tv_sec = 0; - ldap_pvt_runqueue_resched( &slapd_rq, si->si_re, 0 ); - si->si_re->interval.tv_sec = si->si_interval; - } - ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); + ldap_pvt_thread_pool_retract( &connection_pool, + si->si_re->routine, si->si_re ); } ldap_pvt_thread_mutex_unlock( &si->si_mutex ); } } if ( isrunning ) { - si->si_ctype = 0; + si->si_ctype = -1; si->si_next = NULL; } else { syncinfo_free( si, 0 );