Commit fd2d58f3 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Two bugfixes. One caused the receiver to hang. The other prevented select from...

Two bugfixes. One caused the receiver to hang. The other prevented select from noticing that the sender was able to write.
parent b6f0f0ed
...@@ -318,9 +318,10 @@ void receive_sender(int i) { ...@@ -318,9 +318,10 @@ void receive_sender(int i) {
//unsigned long tmpulong, sndsec, sndusec; //unsigned long tmpulong, sndsec, sndusec;
//struct timeval rcvtime; //struct timeval rcvtime;
if (recv_all(snddb[i].sockfd, inbuf, MAX_PAYLOAD_SIZE)== 0) { //connection closed if (recv(snddb[i].sockfd, inbuf, MAX_PAYLOAD_SIZE, 0)== 0) { //connection closed
snddb[i].valid = 0; snddb[i].valid = 0;
FD_CLR(snddb[i].sockfd, &read_fds); FD_CLR(snddb[i].sockfd, &read_fds);
//additional clean-up !!
} else { } else {
/* outdated since we use sniff for delay measurement now /* outdated since we use sniff for delay measurement now
gettimeofday(&rcvtime, NULL); gettimeofday(&rcvtime, NULL);
...@@ -334,6 +335,8 @@ void receive_sender(int i) { ...@@ -334,6 +335,8 @@ void receive_sender(int i) {
} }
} }
int debug_fd = 0;
void send_receiver(unsigned long destaddr, long size, fd_set * write_fds_copy){ void send_receiver(unsigned long destaddr, long size, fd_set * write_fds_copy){
int index; int index;
int sockfd; int sockfd;
...@@ -357,6 +360,7 @@ void send_receiver(unsigned long destaddr, long size, fd_set * write_fds_copy){ ...@@ -357,6 +360,7 @@ void send_receiver(unsigned long destaddr, long size, fd_set * write_fds_copy){
if (FD_ISSET(sockfd, write_fds_copy) || !FD_ISSET(sockfd, &write_fds)) if (FD_ISSET(sockfd, write_fds_copy) || !FD_ISSET(sockfd, &write_fds))
{ {
FD_SET(sockfd, &write_fds); FD_SET(sockfd, &write_fds);
debug_fd = sockfd;
error = send_all(sockfd, random_buffer, size); error = send_all(sockfd, random_buffer, size);
} }
...@@ -481,6 +485,7 @@ void handle_packet_buffer(struct timeval * deadline, fd_set * write_fds_copy) ...@@ -481,6 +485,7 @@ void handle_packet_buffer(struct timeval * deadline, fd_set * write_fds_copy)
// debug_temp.s_addr = packet.ip; // debug_temp.s_addr = packet.ip;
// printf("Sending packet to %s of size %ld\n", inet_ntoa(debug_temp), // printf("Sending packet to %s of size %ld\n", inet_ntoa(debug_temp),
// packet.size); // packet.size);
printf(".");
send_receiver(packet.ip, packet.size, write_fds_copy); send_receiver(packet.ip, packet.size, write_fds_copy);
...@@ -522,7 +527,7 @@ int main(int argc, char *argv[]) { ...@@ -522,7 +527,7 @@ int main(int argc, char *argv[]) {
fd_set read_fds_copy, write_fds_copy; fd_set read_fds_copy, write_fds_copy;
socklen_t sin_size; socklen_t sin_size;
struct timeval start_tv, left_tv; struct timeval start_tv, left_tv;
int yes=1, maxfd, i, flag_send_monitor=0; int yes=1, i, flag_send_monitor=0;
struct timeval packet_deadline; struct timeval packet_deadline;
gettimeofday(&packet_deadline, NULL); gettimeofday(&packet_deadline, NULL);
...@@ -611,6 +616,8 @@ int main(int argc, char *argv[]) { ...@@ -611,6 +616,8 @@ int main(int argc, char *argv[]) {
flag_send_monitor=0; //reset flag for each quanta flag_send_monitor=0; //reset flag for each quanta
gettimeofday(&start_tv, NULL); //reset start time for each quanta gettimeofday(&start_tv, NULL); //reset start time for each quanta
printf("quanta\n");
//while in a quanta //while in a quanta
while(have_time(&start_tv, &left_tv)) { while(have_time(&start_tv, &left_tv)) {
read_fds_copy = read_fds; read_fds_copy = read_fds;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment