diff --git a/src/sender_utils.c b/src/sender_utils.c index 08b6b437161e52c748db96b0ed774d3a883ff479..db31c725e66f902745039abe801e3f323d30dabc 100644 --- a/src/sender_utils.c +++ b/src/sender_utils.c @@ -151,7 +151,8 @@ int handle_returning_ack_nack(sender_state_t *state, int socket_fd) state->r_window_size = r_window; uint8_t upper_bound = (place_last_ack + 1) % WINDOW_SIZE; // The oldest seqnum sended - while (state->tail != upper_bound) + // A do while is necessary here in case we want to make a full revolution (ack from 1 to 1 not included for example) + do { pkt_t *n_pkt = state->buffer[state->tail]; seqnum = pkt_get_seqnum(n_pkt); @@ -162,7 +163,7 @@ int handle_returning_ack_nack(sender_state_t *state, int socket_fd) state->s_window_size++; state->tail = (state->tail + 1) % WINDOW_SIZE; - } + } while (state->tail != upper_bound); // Send back the asked ACK if there is one to send back if (place_last_nack != OUT_OFF_WINDOW)