summaryrefslogtreecommitdiffstats
path: root/lib/thread.c
diff options
context:
space:
mode:
authorjardin <jardin>2003-12-23 08:56:18 +0000
committerjardin <jardin>2003-12-23 08:56:18 +0000
commitaccc3fe2638b3d69e6561171f2dd99f1afd83cf8 (patch)
treeca748729716d0511cdf96bb3fb48ce02a8b43586 /lib/thread.c
parent07ce4061d272721d5b5bb15869150a159d34a7d8 (diff)
downloadquagga-accc3fe2638b3d69e6561171f2dd99f1afd83cf8.tar.bz2
quagga-accc3fe2638b3d69e6561171f2dd99f1afd83cf8.tar.xz
Merge isisd into the Quagga's framework:
- add privs support - use misc quagga's definitions - make it compile"able" - fix segfault cases related to hostname() - add debug isis xxx command This patch has been approved by Paul Jakma.
Diffstat (limited to 'lib/thread.c')
-rw-r--r--lib/thread.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/thread.c b/lib/thread.c
index 402167cf..93809f2f 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -518,6 +518,46 @@ funcname_thread_add_timer (struct thread_master *m,
return thread;
}
+/* Add timer event thread with "millisecond" resolution */
+struct thread *
+funcname_thread_add_timer_msec (struct thread_master *m,
+ int (*func) (struct thread *), void *arg, long timer, char* funcname)
+{
+ struct timeval timer_now;
+ struct thread *thread;
+#ifndef TIMER_NO_SORT
+ struct thread *tt;
+#endif /* TIMER_NO_SORT */
+
+ assert (m != NULL);
+
+ thread = thread_get (m, THREAD_TIMER, func, arg, funcname);
+
+ timer = 1000*timer; /* milli -> micro */
+
+ /* Do we need jitter here? */
+ gettimeofday (&timer_now, NULL);
+ timer_now.tv_sec += timer / TIMER_SECOND_MICRO;
+ timer_now.tv_usec += (timer % TIMER_SECOND_MICRO);
+ thread->u.sands = timer_now;
+
+ /* Sort by timeval. */
+#ifdef TIMER_NO_SORT
+ thread_list_add (&m->timer, thread);
+#else
+ for (tt = m->timer.head; tt; tt = tt->next)
+ if (timeval_cmp (thread->u.sands, tt->u.sands) <= 0)
+ break;
+
+ if (tt)
+ thread_list_add_before (&m->timer, tt, thread);
+ else
+ thread_list_add (&m->timer, thread);
+#endif /* TIMER_NO_SORT */
+
+ return thread;
+}
+
/* Add simple event thread. */
struct thread *
funcname_thread_add_event (struct thread_master *m,