aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcbin35294 -> 35294 bytes
-rwxr-xr-xlbin34638 -> 34638 bytes
-rw-r--r--l.dSYM/Contents/Resources/DWARF/lbin11651 -> 11651 bytes
-rw-r--r--listener.c1
-rw-r--r--mp3/chipOffTheBlock.mp3bin0 -> 4477733 bytes
-rwxr-xr-xsbin55198 -> 55198 bytes
-rw-r--r--s.dSYM/Contents/Resources/DWARF/sbin23594 -> 23649 bytes
-rw-r--r--snowcast_server_concurrent.c25
8 files changed, 17 insertions, 9 deletions
diff --git a/c b/c
index 35031be..20b2474 100755
--- a/c
+++ b/c
Binary files differ
diff --git a/l b/l
index 281f522..d6eec69 100755
--- a/l
+++ b/l
Binary files differ
diff --git a/l.dSYM/Contents/Resources/DWARF/l b/l.dSYM/Contents/Resources/DWARF/l
index c55216a..283ecc9 100644
--- a/l.dSYM/Contents/Resources/DWARF/l
+++ b/l.dSYM/Contents/Resources/DWARF/l
Binary files differ
diff --git a/listener.c b/listener.c
index d5b4799..7bb8afe 100644
--- a/listener.c
+++ b/listener.c
@@ -102,7 +102,6 @@ int main(int argc, char *argv[])
//printf("listener: packet contains \"%s\"\n", buf);
// print the size
-
write(STDOUT_FILENO, buf, numbytes);
memset(buf, 0, MAXBUFLEN);
diff --git a/mp3/chipOffTheBlock.mp3 b/mp3/chipOffTheBlock.mp3
new file mode 100644
index 0000000..c06c05f
--- /dev/null
+++ b/mp3/chipOffTheBlock.mp3
Binary files differ
diff --git a/s b/s
index 10bc785..9f86c9b 100755
--- a/s
+++ b/s
Binary files differ
diff --git a/s.dSYM/Contents/Resources/DWARF/s b/s.dSYM/Contents/Resources/DWARF/s
index 4db3832..489e060 100644
--- a/s.dSYM/Contents/Resources/DWARF/s
+++ b/s.dSYM/Contents/Resources/DWARF/s
Binary files differ
diff --git a/snowcast_server_concurrent.c b/snowcast_server_concurrent.c
index 3b71156..47b112a 100644
--- a/snowcast_server_concurrent.c
+++ b/snowcast_server_concurrent.c
@@ -240,8 +240,8 @@ void *send_udp_packet_routine(void *arg) {
// get file path
char* file_path = station_data[station_num].filePath;
// get current seek chunk
- int current_chunk = station_data[station_num].seekIndex;
FILE* file_stream = fopen(file_path, "r");
+ int current_chunk = station_data[station_num].seekIndex;
if (fseek(file_stream, current_chunk, SEEK_SET) == -1) {
perror("fseek");
return (NULL);
@@ -253,6 +253,7 @@ void *send_udp_packet_routine(void *arg) {
perror("fread");
return (NULL);
}
+ fclose(file_stream);
// printf("send data: thread %d \n", user_index);
// int numbytes;
// if ((numbytes = sendto(udp_sockfd, data, strlen(data), 0,
@@ -273,7 +274,6 @@ void *send_udp_packet_routine(void *arg) {
did_work = 1;
- close(file_stream);
usleep(400000);
}
@@ -507,16 +507,24 @@ void *init_user(int sockfd) {
// this is to save memory space.
// in general, the displacement of 4 is where a user "used to be"
int user_index = max_active_users++;
- if(user_data[(sockfd-4)/2].sockfd == -1) {
- printf("reusing memory\n");
- user_index = (sockfd - 4)/2;
- } else {
- printf("making new memory\n");
- // have to make more memory
+ int running_index = 0;
+ while(running_index++ < max_active_users)
+ {
+ if (user_data[running_index].sockfd == -1)
+ {
+ user_index = running_index;
+ break;
+ }
+ // printf("reusing memory\n");
+ }
+ // have to make more memory
+ if (user_index == max_active_users) {
+ ///printf("making new memory\n");
user_t *more_users = realloc(user_data, sizeof(user_t) * max_active_users);
if (!more_users) { perror("realloc"); exit(1); }
user_data = more_users;
}
+
// map TCP sockfd to this user index
user_data[user_index] = (user_t){-1, -1, sockfd, -1};
sockfd_to_user[sockfd] = user_index;
@@ -585,4 +593,5 @@ void send_announce_message(int fd, int station_num) {
printf("sent %d bytes\n", bytessent);
free(send_buffer);
+
} \ No newline at end of file