]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Coroutines: Adapted to new timers and set to pthreads if possible
authorJan Maria Matejka <mq@ucw.cz>
Tue, 28 Aug 2018 11:12:25 +0000 (13:12 +0200)
committerJan Maria Matejka <mq@ucw.cz>
Tue, 28 Aug 2018 11:12:25 +0000 (13:12 +0200)
sysdep/unix/coroutine.c

index 5e986a7ca4dcb02e792a3e43324a82d0f07921fa..c5a2ba7390610b0ad026fcf5c6fec713b069739d 100644 (file)
 #include "lib/coroutine.h"
 #include "lib/resource.h"
 #include "lib/socket.h"
+#include "lib/timer.h"
 #include "sysdep/unix/unix.h"
 
 #define CORO_STACK_SIZE 65536
 
-#if 1
+#if ! USE_PTHREADS
 
 /*
  *     Implementation of coroutines based on <ucontext.h>
@@ -170,10 +171,13 @@ static struct resclass coro_class = {
   .memsize = coro_memsize,
 };
 
+extern pthread_key_t current_time_key;
+
 static void *
 coro_do_start(void *c_)
 {
   coroutine *c = c_;
+  pthread_setspecific(current_time_key, &main_timeloop);
   while (sem_wait(&c->sem) < 0)
     ;
   coro_current = c;