From: Jong Hyuk Choi Date: Tue, 20 May 2003 23:52:11 +0000 (+0000) Subject: select loop changes for persistent threads X-Git-Tag: OPENLDAP_REL_ENG_2_2_0ALPHA~95 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4192c4aaaa66f33e066b42f4afc501bf602bd1b7;p=openldap select loop changes for persistent threads --- diff --git a/include/ldap_rq.h b/include/ldap_rq.h index db83a8da1d..0c1d1c158f 100644 --- a/include/ldap_rq.h +++ b/include/ldap_rq.h @@ -61,4 +61,9 @@ ldap_pvt_runqueue_resched( struct re_s* entry ); +LDAP_F( int ) +ldap_pvt_runqueue_persistent_backload( + struct runqueue_s* rq +); + #endif diff --git a/libraries/libldap_r/rq.c b/libraries/libldap_r/rq.c index 6977405fe4..8aa9b0b76a 100644 --- a/libraries/libldap_r/rq.c +++ b/libraries/libldap_r/rq.c @@ -69,6 +69,9 @@ ldap_pvt_runqueue_next_sched( if ( entry == NULL ) { *next_run = NULL; return NULL; + } else if ( entry->next_sched.tv_sec == 0 ) { + *next_run = NULL; + return NULL; } else { *next_run = &entry->next_sched; return entry; @@ -127,22 +130,54 @@ ldap_pvt_runqueue_resched( LDAP_STAILQ_REMOVE( &rq->task_list, entry, re_s, tnext ); - entry->next_sched.tv_sec = time( NULL ) + entry->interval.tv_sec; + if ( entry->interval.tv_sec ) { + entry->next_sched.tv_sec = time( NULL ) + entry->interval.tv_sec; + } else { + entry->next_sched.tv_sec = 0; + } + if ( LDAP_STAILQ_EMPTY( &rq->task_list )) { LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext ); + } else if ( entry->next_sched.tv_sec == 0 ) { + LDAP_STAILQ_INSERT_TAIL( &rq->task_list, entry, tnext ); } else { prev = NULL; LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) { - if ( e->next_sched.tv_sec > entry->next_sched.tv_sec ) { + if ( e->next_sched.tv_sec == 0 ) { + if ( prev == NULL ) { + LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext ); + } else { + LDAP_STAILQ_INSERT_AFTER( &rq->task_list, prev, entry, tnext ); + } + break; + } else if ( e->next_sched.tv_sec > entry->next_sched.tv_sec ) { if ( prev == NULL ) { LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext ); } else { LDAP_STAILQ_INSERT_AFTER( &rq->task_list, prev, entry, tnext ); } + break; } prev = e; } } } +int +ldap_pvt_runqueue_persistent_backload( + struct runqueue_s* rq +) +{ + struct re_s* e; + int count = 0; + + if ( !LDAP_STAILQ_EMPTY( &rq->task_list )) { + LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) { + if ( e->next_sched.tv_sec == 0 ) + count++; + } + } + return count; +} + #endif diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 2afa9767ab..a0b8e92fc2 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -1329,8 +1329,10 @@ slapd_daemon_task( ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); - if ( !at ) - at = ldap_pvt_thread_pool_backload(&connection_pool); + if ( !at ) { + at = ldap_pvt_thread_pool_backload(&connection_pool) - + ldap_pvt_runqueue_persistent_backload( &syncrepl_rq ); + } tvp = at ? &tv : NULL;