]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9878 Treat tasks with interval == 0 as one-shot
authorOndřej Kuzník <ondra@mistotebe.net>
Wed, 7 Sep 2022 08:53:57 +0000 (09:53 +0100)
committerOndřej Kuzník <ondra@mistotebe.net>
Thu, 8 Sep 2022 07:31:22 +0000 (08:31 +0100)
Some tasks need to be run once at a given time or the earliest
opportunity, also currently, using interval == 0 on a task triggers
a busy loop inside the scheduling task, halting progress for other
tasks and any other work usually serviced by that thread.

This change deals with both issues at the same time.

servers/slapd/daemon.c

index d508be22089cdd9fd7debfff729983777c594740..e26e962b57f2caa4b4c8851ab4f8f68cc799c7f8 100644 (file)
@@ -2788,11 +2788,13 @@ loop:
                        ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
                        rtask = ldap_pvt_runqueue_next_sched( &slapd_rq, &cat );
                        while ( rtask && cat.tv_sec && cat.tv_sec <= now ) {
+                               /* ITS#9878 If interval == 0, this task was meant to be one-shot */
+                               int defer = !rtask->interval.tv_sec;
                                if ( ldap_pvt_runqueue_isrunning( &slapd_rq, rtask )) {
-                                       ldap_pvt_runqueue_resched( &slapd_rq, rtask, 0 );
+                                       ldap_pvt_runqueue_resched( &slapd_rq, rtask, defer );
                                } else {
                                        ldap_pvt_runqueue_runtask( &slapd_rq, rtask );
-                                       ldap_pvt_runqueue_resched( &slapd_rq, rtask, 0 );
+                                       ldap_pvt_runqueue_resched( &slapd_rq, rtask, defer );
                                        ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
                                        ldap_pvt_thread_pool_submit2( &connection_pool,
                                                slapd_rtask_trampoline, (void *) rtask, &rtask->pool_cookie );