aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-09-26 00:40:26 -0400
committersotech117 <michael_foiani@brown.edu>2023-09-26 00:40:26 -0400
commit250c7b721e4be987b5ff090de096dbb2c61ecf6c (patch)
treef80eedf697fc2f9fb5045e837abd8a22a86a4ca5
parent172a46063a25b2b49072b3e74b4ce3fdb137032a (diff)
found the bug, attempting fixes
-rw-r--r--server.c8
1 files changed, 4 insertions, 4 deletions
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);