]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap_r/rq.c
Add task names to runqueue entries
[openldap] / libraries / libldap_r / rq.c
index 85ae1aa2db99e810132c88174e5e37ad83bdcac1..99daef6ca1baefe6f59ffc54d7b6f8870650e2cb 100644 (file)
 #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_TAIL( &rq->task_list, entry, tnext );
+       }
+       return entry;
+}
+
+struct re_s *
+ldap_pvt_runqueue_find(
+       struct runqueue_s *rq,
+       ldap_pvt_thread_start_t *routine,
+       void *arg
+)
+{
+       struct re_s* e;
+
+       LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) {
+               if ( e->routine == routine && e->arg == arg )
+                       return e;
+       }
+       return NULL;
 }
 
 void