From 250c7b721e4be987b5ff090de096dbb2c61ecf6c Mon Sep 17 00:00:00 2001 From: sotech117 Date: Tue, 26 Sep 2023 00:40:26 -0400 Subject: found the bug, attempting fixes --- server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server.c') diff --git a/server.c b/server.c index feb62c9..af1551e 100644 --- a/server.c +++ b/server.c @@ -294,7 +294,7 @@ int setup_stations(int argc, char *argv[]) { stations[i].filePath = argv[i+2]; stations[i].readfd = open(argv[i+2], O_RDONLY); if (stations[i].readfd < 0) { perror("read (from station file)"); return -1; } - pthread_create(&stations[i].streamThread, NULL, stream_routine, (void *) &i); + pthread_create(&stations[i].streamThread, NULL, stream_routine, i); } return 1; @@ -308,7 +308,7 @@ int setup_stations(int argc, char *argv[]) { note: you can modify how often and how much is read off the file by changing the MACROS */ void *stream_routine(void *arg) { - int station_num = * (int*) arg; + int station_num = (int) arg; // printf("stream routine %d\n", station_num); int read_fd = stations[station_num].readfd; @@ -1125,7 +1125,7 @@ void add_station(char *file_path) { // reopen the file stations[i].readfd = open(file_path, O_RDONLY); if (stations[i].readfd < 0) { perror("read (from add station)"); return; } - pthread_create(&stations[i].streamThread, NULL, stream_routine, (void *) &i); + pthread_create(&stations[i].streamThread, NULL, stream_routine, i); send_newstation_reply(i); return; @@ -1154,7 +1154,7 @@ void add_station(char *file_path) { fdmax = stations[num_stations].readfd; } if (stations[num_stations].readfd < 0) { perror("read (from add station)"); return; } - pthread_create(&stations[num_stations].streamThread, NULL, stream_routine, (void *) &num_stations); + pthread_create(&stations[num_stations].streamThread, NULL, stream_routine, num_stations); send_newstation_reply(num_stations); printf("add: successfully created station @ index %d\n", num_stations); -- cgit v1.2.3-70-g09d2