summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ot_udp.c16
-rw-r--r--ot_udp.h1
-rw-r--r--trackerlogic.c2
3 files changed, 19 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}
diff --git a/ot_udp.h b/ot_udp.h
index a71a3d9..db48696 100644
--- a/ot_udp.h
+++ b/ot_udp.h
@@ -7,6 +7,7 @@
7#define OT_UDP_H__ 7#define OT_UDP_H__
8 8
9void udp_init(int64 sock, unsigned int worker_count); 9void udp_init(int64 sock, unsigned int worker_count);
10void udp_kickoff(void);
10int handle_udp6(int64 serversocket, struct ot_workstruct *ws); 11int handle_udp6(int64 serversocket, struct ot_workstruct *ws);
11 12
12#endif 13#endif
diff --git a/trackerlogic.c b/trackerlogic.c
index cacb12b..7c6b7e1 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -28,6 +28,7 @@
28#include "ot_mutex.h" 28#include "ot_mutex.h"
29#include "ot_stats.h" 29#include "ot_stats.h"
30#include "ot_vector.h" 30#include "ot_vector.h"
31#include "ot_udp.h"
31#include "trackerlogic.h" 32#include "trackerlogic.h"
32 33
33/* Forward declaration */ 34/* Forward declaration */
@@ -566,6 +567,7 @@ void trackerlogic_init(void) {
566 accesslist_init(); 567 accesslist_init();
567 livesync_init(); 568 livesync_init();
568 stats_init(); 569 stats_init();
570 udp_kickoff();
569} 571}
570 572
571void trackerlogic_deinit(void) { 573void trackerlogic_deinit(void) {