From a0363c2c3bf734d07babfafc531b8fc7baf91081 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 19 Oct 2026 02:26:29 +0200 Subject: Hold off starting udp workers until trackerlogic finished initialising --- ot_udp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ot_udp.c') 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}; static volatile uint32_t g_key_of_the_hour[2] = {0}; static volatile ot_time g_hour_of_the_key; +static pthread_mutex_t udp_start_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t udp_start_cond = PTHREAD_COND_INITIALIZER; +static int g_opentracker_started = 0; + static void udp_generate_rijndael_round_key(void) { uint32_t key[16]; #ifdef WANT_ARC4RANDOM @@ -223,6 +227,11 @@ static void *udp_worker(void *args) { ws.debugbuf = malloc(G_DEBUGBUF_SIZE); #endif + pthread_mutex_lock(&udp_start_mutex); + while(g_opentracker_running && !g_opentracker_started) + pthread_cond_wait(&udp_start_cond, &udp_start_mutex); + pthread_mutex_unlock(&udp_start_mutex); + while (g_opentracker_running) handle_udp6(sock, &ws); @@ -244,3 +253,10 @@ void udp_init(int64 sock, unsigned int worker_count) { while (worker_count--) pthread_create(&thread_id, NULL, udp_worker, (void *)sock); } + +void udp_kickoff(void) { + pthread_mutex_lock(&udp_start_mutex); + g_opentracker_started = 1; + pthread_cond_broadcast(&udp_start_cond); + pthread_mutex_unlock(&udp_start_mutex); +} -- cgit v1.3