modified for termination when used for mictcp video replay

This commit is contained in:
Nicolas Van Wambeke 2016-06-19 11:47:13 +02:00
parent 769f757fec
commit dc7fb0af27

View file

@ -241,9 +241,10 @@ void file_to_mictcp(struct sockaddr_in listen_on, struct sockaddr_in transmit_to
struct timespec currentTime; struct timespec currentTime;
struct timespec rem; struct timespec rem;
int firstValue = 0; int firstValue = 0;
int active = 1;
// Main activity loop, we never exit this, user terminates with SIGKILL // Main activity loop, we exit this at the end of the file
while(1) { while(active) {
bzero(buffer, MAX_UDP_SEGMENT_SIZE); bzero(buffer, MAX_UDP_SEGMENT_SIZE);
n = fread(&currentTimeFile, 1, sizeof(struct timespec), fd); n = fread(&currentTimeFile, 1, sizeof(struct timespec), fd);
@ -266,9 +267,12 @@ void file_to_mictcp(struct sockaddr_in listen_on, struct sockaddr_in transmit_to
lastTimeFile = currentTimeFile; lastTimeFile = currentTimeFile;
n = fread(buffer, 1, sizeof(n), fd); n = fread(buffer, 1, sizeof(n), fd);
n = fread(buffer, 1, *((int *)buffer), fd); n = fread(buffer, 1, *((int *)buffer), fd);
if (n < 0) { if (n <= 0) {
if(n < 0) {
perror(0); perror(0);
} }
active = 0;
}
// We forward the packet to its final destination // We forward the packet to its final destination
n = mic_tcp_send(mic_tcp_sockfd, buffer, n); n = mic_tcp_send(mic_tcp_sockfd, buffer, n);
@ -277,7 +281,7 @@ void file_to_mictcp(struct sockaddr_in listen_on, struct sockaddr_in transmit_to
} }
} }
// We never execute this but anyway, for sanity // We execute this when the file has finished being replayed
close(listen_sockfd); close(listen_sockfd);
// Same for MICTCP // Same for MICTCP