diff options
| -rw-r--r-- | ot_udp.c | 16 | ||||
| -rw-r--r-- | ot_udp.h | 1 | ||||
| -rw-r--r-- | trackerlogic.c | 2 |
3 files changed, 19 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 | } | ||
| @@ -7,6 +7,7 @@ | |||
| 7 | #define OT_UDP_H__ | 7 | #define OT_UDP_H__ |
| 8 | 8 | ||
| 9 | void udp_init(int64 sock, unsigned int worker_count); | 9 | void udp_init(int64 sock, unsigned int worker_count); |
| 10 | void udp_kickoff(void); | ||
| 10 | int handle_udp6(int64 serversocket, struct ot_workstruct *ws); | 11 | int 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 | ||
| 571 | void trackerlogic_deinit(void) { | 573 | void trackerlogic_deinit(void) { |
