aboutsummaryrefslogtreecommitdiff
path: root/snowcast_server_concurrent.c
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-09-20 02:19:24 -0400
committersotech117 <michael_foiani@brown.edu>2023-09-20 02:19:24 -0400
commit005eaf49da54d72e00400c550664dae9469007dc (patch)
treefc88bb3575d2c84d398915c43f3d9466deace2b1 /snowcast_server_concurrent.c
parentb3e7054694b8cac62c7ea2ca07da960b43ac6d24 (diff)
fix some other tests i broke. small index bug
Diffstat (limited to 'snowcast_server_concurrent.c')
-rw-r--r--snowcast_server_concurrent.c39
1 files changed, 23 insertions, 16 deletions
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);
}
}