]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap_r/rq.c
ITS#2562: add missing arg to hash_lanman
[openldap] / libraries / libldap_r / rq.c
index 6977405fe4700d6155c534449fc455e2a8718206..29153ccc7270ef1d7b260ef4d65ae627cfeb7fd4 100644 (file)
@@ -1,4 +1,8 @@
 /* $OpenLDAP$ */
+/* 
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 #include "portable.h"
 
 #include <stdio.h>
@@ -14,8 +18,6 @@
 #include "ldap_queue.h"
 #include "ldap_rq.h"
 
-#ifdef LDAP_SYNCREPL
-
 void
 ldap_pvt_runqueue_insert(
        struct runqueue_s* rq,
@@ -69,6 +71,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 +132,53 @@ 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;
                }
        }
 }
 
-#endif
+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;
+}
+