diff options
Diffstat (limited to 'ot_udp.c')
| -rw-r--r-- | ot_udp.c | 16 |
1 files changed, 16 insertions, 0 deletions
| @@ -28,6 +28,10 @@ static uint32_t g_rijndael_round_key[44] = {0}; | |||
| 28 | static volatile uint32_t g_key_of_the_hour[2] = {0}; | 28 | static volatile uint32_t g_key_of_the_hour[2] = {0}; |
| 29 | static volatile ot_time g_hour_of_the_key; | 29 | static volatile ot_time g_hour_of_the_key; |
| 30 | 30 | ||
| 31 | static pthread_mutex_t udp_start_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
| 32 | static pthread_cond_t udp_start_cond = PTHREAD_COND_INITIALIZER; | ||
| 33 | static int g_opentracker_started = 0; | ||
| 34 | |||
| 31 | static void udp_generate_rijndael_round_key(void) { | 35 | static void udp_generate_rijndael_round_key(void) { |
| 32 | uint32_t key[16]; | 36 | uint32_t key[16]; |
| 33 | #ifdef WANT_ARC4RANDOM | 37 | #ifdef WANT_ARC4RANDOM |
| @@ -223,6 +227,11 @@ static void *udp_worker(void *args) { | |||
| 223 | ws.debugbuf = malloc(G_DEBUGBUF_SIZE); | 227 | ws.debugbuf = malloc(G_DEBUGBUF_SIZE); |
| 224 | #endif | 228 | #endif |
| 225 | 229 | ||
| 230 | pthread_mutex_lock(&udp_start_mutex); | ||
| 231 | while(g_opentracker_running && !g_opentracker_started) | ||
| 232 | pthread_cond_wait(&udp_start_cond, &udp_start_mutex); | ||
| 233 | pthread_mutex_unlock(&udp_start_mutex); | ||
| 234 | |||
| 226 | while (g_opentracker_running) | 235 | while (g_opentracker_running) |
| 227 | handle_udp6(sock, &ws); | 236 | handle_udp6(sock, &ws); |
| 228 | 237 | ||
| @@ -244,3 +253,10 @@ void udp_init(int64 sock, unsigned int worker_count) { | |||
| 244 | while (worker_count--) | 253 | while (worker_count--) |
| 245 | pthread_create(&thread_id, NULL, udp_worker, (void *)sock); | 254 | pthread_create(&thread_id, NULL, udp_worker, (void *)sock); |
| 246 | } | 255 | } |
| 256 | |||
| 257 | void udp_kickoff(void) { | ||
| 258 | pthread_mutex_lock(&udp_start_mutex); | ||
| 259 | g_opentracker_started = 1; | ||
| 260 | pthread_cond_broadcast(&udp_start_cond); | ||
| 261 | pthread_mutex_unlock(&udp_start_mutex); | ||
| 262 | } | ||
