ITS#9878 Have refint use interval 0 to schedule its task

Since the task is not rescheduled until a new operation comes in, close
a race where the reschedule chooses to stop it while the new item is
being added.
This commit is contained in:
Ondřej Kuzník 2022-09-23 12:55:38 +01:00 committed by Quanah Gibson-Mount
parent 148204839f
commit a779f148a0

View file

@ -96,8 +96,6 @@ typedef struct refint_pre_s {
int do_sub;
} refint_pre;
#define RUNQ_INTERVAL 36000 /* a long time */
static MatchingRule *mr_dnSubtreeMatch;
enum {
@ -921,18 +919,18 @@ refint_qtask( void *ctx, void *arg )
fptr = f_next;
}
/* wait until we get explicitly scheduled again */
/* wait until there's more work to do */
ldap_pvt_thread_mutex_lock( &id->qmutex );
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
ldap_pvt_runqueue_stoptask( &slapd_rq, id->qtask );
if ( pausing ) {
/* try to run again as soon as the pause is done */
id->qtask->interval.tv_sec = 0;
if ( pausing || id->qhead ) {
/* try to run again when possible */
ldap_pvt_runqueue_resched( &slapd_rq, id->qtask, 0 );
id->qtask->interval.tv_sec = RUNQ_INTERVAL;
} else {
ldap_pvt_runqueue_resched( &slapd_rq,id->qtask, 1 );
ldap_pvt_runqueue_resched( &slapd_rq, id->qtask, 1 );
}
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
ldap_pvt_thread_mutex_unlock( &id->qmutex );
return NULL;
}
@ -986,15 +984,12 @@ refint_response(
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
if ( !id->qtask ) {
id->qtask = ldap_pvt_runqueue_insert( &slapd_rq, RUNQ_INTERVAL,
id->qtask = ldap_pvt_runqueue_insert( &slapd_rq, 0,
refint_qtask, id, "refint_qtask",
op->o_bd->be_suffix[0].bv_val );
} else {
if ( !ldap_pvt_runqueue_isrunning( &slapd_rq, id->qtask ) &&
!id->qtask->next_sched.tv_sec ) {
id->qtask->interval.tv_sec = 0;
if ( !ldap_pvt_runqueue_isrunning( &slapd_rq, id->qtask ) ) {
ldap_pvt_runqueue_resched( &slapd_rq, id->qtask, 0 );
id->qtask->interval.tv_sec = RUNQ_INTERVAL;
}
}
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );