summaryrefslogtreecommitdiff
path: root/ot_udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_udp.c')
-rw-r--r--ot_udp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ot_udp.c b/ot_udp.c
index 26fb979..fae2c87 100644
--- a/ot_udp.c
+++ b/ot_udp.c
@@ -28,6 +28,10 @@ static uint32_t g_rijndael_round_key[44] = {0};
28static volatile uint32_t g_key_of_the_hour[2] = {0}; 28static volatile uint32_t g_key_of_the_hour[2] = {0};
29static volatile ot_time g_hour_of_the_key; 29static volatile ot_time g_hour_of_the_key;
30 30
31static pthread_mutex_t udp_start_mutex = PTHREAD_MUTEX_INITIALIZER;
32static pthread_cond_t udp_start_cond = PTHREAD_COND_INITIALIZER;
33static int g_opentracker_started = 0;
34
31static void udp_generate_rijndael_round_key(void) { 35static 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
257void 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}