From 2c7659ec930277981b6333b5b3aff7840d11933c Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 25 Oct 2026 18:51:51 +0100 Subject: Decouple config parsing from binding and worker spawning * Options are parsed now into a listener description list before binding them at once and starting the workers later * UDP workers can now be configured per connection * socket reuse is now done more sensibly, mcast sockets always reused * Hold-off logic after spawning udp workers removed --- ot_udp.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'ot_udp.c') diff --git a/ot_udp.c b/ot_udp.c index dc8267c..7f6517f 100644 --- a/ot_udp.c +++ b/ot_udp.c @@ -26,9 +26,6 @@ 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]; @@ -211,11 +208,6 @@ 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); @@ -227,20 +219,18 @@ static void *udp_worker(void *args) { return NULL; } -void udp_init(int64_t sock, unsigned int worker_count) { - pthread_t thread_id; +void udp_init(void) { if (!g_rijndael_round_key[0]) udp_generate_rijndael_round_key(); +} + +void udp_workers_install(int64_t sock, unsigned int worker_count) { + pthread_t thread_id; + #ifdef _DEBUG - fprintf(stderr, " installing %d workers on udp socket %ld\n", worker_count, (unsigned long)sock); + fprintf(stderr, "Installing %d workers on udp socket %ld\n", worker_count, (unsigned long)sock); #endif 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