]> git.sur5r.net Git - openldap/commitdiff
runqueue locking fix (ITS#2746)
authorJong Hyuk Choi <jongchoi@openldap.org>
Sun, 12 Oct 2003 09:13:04 +0000 (09:13 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Sun, 12 Oct 2003 09:13:04 +0000 (09:13 +0000)
libraries/libldap_r/rq.c
servers/slapd/daemon.c

index 88851efeb7adf5a63258847692bfb73c6516170c..16a81115016b85fb4bac5289c42c2e57581d521c 100644 (file)
@@ -174,12 +174,14 @@ ldap_pvt_runqueue_persistent_backload(
        struct re_s* e;
        int count = 0;
 
+       ldap_pvt_thread_mutex_lock( &rq->rq_mutex );
        if ( !LDAP_STAILQ_EMPTY( &rq->task_list )) {
                LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) {
                        if ( e->next_sched.tv_sec == 0 )
                                count++;
                }
        }
+       ldap_pvt_thread_mutex_unlock( &rq->rq_mutex );
        return count;
 }
 
index d83974becef47da5ef7651388d59a186f4d3e467..c8283828bd803cb98a7c1560727094555806e622 100644 (file)
@@ -1358,9 +1358,9 @@ slapd_daemon_task(
                                ldap_pvt_thread_pool_submit( &connection_pool,
                                                                                        rtask->routine, (void *) rtask );
                        }
+                       ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
                        rtask = ldap_pvt_runqueue_next_sched( &syncrepl_rq, &cat );
                }
-               rtask = ldap_pvt_runqueue_next_sched( &syncrepl_rq, &cat );
                ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
 
                if ( cat != NULL ) {