From 005eaf49da54d72e00400c550664dae9469007dc Mon Sep 17 00:00:00 2001 From: sotech117 Date: Wed, 20 Sep 2023 02:19:24 -0400 Subject: fix some other tests i broke. small index bug --- snowcast_server_concurrent.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'snowcast_server_concurrent.c') diff --git a/snowcast_server_concurrent.c b/snowcast_server_concurrent.c index 92b2dee..bb3eee9 100644 --- a/snowcast_server_concurrent.c +++ b/snowcast_server_concurrent.c @@ -371,6 +371,27 @@ void *send_udp_packet_routine(void *arg) { return NULL; } +void *send_announce_routine(void *arg) { + // unpack args + int station_num = (int) arg; + // send the announce messages + for (int i = 0; i < max_active_users; i++) + { + // if (user_data[i].streamThread == NULL) { + // break; + // } + if (user_data[i].sockfd == -1) + continue; + // print_user_data(i); + // update the station of each user + if (user_data[i].stationNum == station_num) + { + // printf("sending announce to user %d\n", i); + send_announce_reply(user_data[i].sockfd, i); + } + } +} + void *synchronization_thread(void *arg) { int c = 0; while (1) @@ -404,22 +425,8 @@ void *synchronization_thread(void *arg) { station_data[i].seekIndex = 0; // printf("resetting station %d\n", i); - // send the announce messages - for (int j = 0; j < max_active_users; i++) - { - // if (user_data[i].streamThread == NULL) { - // break; - // } - if (user_data[j].sockfd == -1) - continue; - // print_user_data(i); - // update the station of each user - if (user_data[j].stationNum == i) - { - // printf("sending announce to user %d\n", i); - send_announce_reply(user_data[j].sockfd, i); - } - } + pthread_t send_announce_thread; + pthread_create(&send_announce_thread, NULL, send_announce_routine, (void *)i); } } -- cgit v1.2.3-70-g09d2