]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap_r/rq.c
Silence warning in print_deref(): cast lutil_b64_ntop() arg to unsigned char*
[openldap] / libraries / libldap_r / rq.c
index bafb12166d62aa8ae70ed4ce7d859217089c0a08..ccd255949e003e70500443f85231c555b49d41d7 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Copyright 2003-2009 The OpenLDAP Foundation.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
  *
 #include "ldap_queue.h"
 #include "ldap_rq.h"
 
-void
+struct re_s *
 ldap_pvt_runqueue_insert(
        struct runqueue_s* rq,
        time_t interval,
        ldap_pvt_thread_start_t *routine,
-       void *arg
+       void *arg,
+       char *tname,
+       char *tspec
 )
 {
        struct re_s* entry;
 
        entry = (struct re_s *) LDAP_CALLOC( 1, sizeof( struct re_s ));
-       entry->interval.tv_sec = interval;
-       entry->interval.tv_usec = 0;
-       entry->next_sched.tv_sec = time( NULL );
-       entry->next_sched.tv_usec = 0;
-       entry->routine = routine;
-       entry->arg = arg;
-       LDAP_STAILQ_INSERT_TAIL( &rq->task_list, entry, tnext );
+       if ( entry ) {
+               entry->interval.tv_sec = interval;
+               entry->interval.tv_usec = 0;
+               entry->next_sched.tv_sec = time( NULL );
+               entry->next_sched.tv_usec = 0;
+               entry->routine = routine;
+               entry->arg = arg;
+               entry->tname = tname;
+               entry->tspec = tspec;
+               LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext );
+       }
+       return entry;
 }
 
 struct re_s *
@@ -92,20 +99,16 @@ ldap_pvt_runqueue_remove(
 struct re_s*
 ldap_pvt_runqueue_next_sched(
        struct runqueue_s* rq,
-       struct timeval** next_run
+       struct timeval* next_run
 )
 {
        struct re_s* entry;
 
        entry = LDAP_STAILQ_FIRST( &rq->task_list );
-       if ( entry == NULL ) {
-               *next_run = NULL;
-               return NULL;
-       } else if ( entry->next_sched.tv_sec == 0 ) {
-               *next_run = NULL;
+       if ( entry == NULL || entry->next_sched.tv_sec == 0 ) {
                return NULL;
        } else {
-               *next_run = &entry->next_sched;
+               *next_run = entry->next_sched;
                return entry;
        }
 }