You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Client 1 calls APPLICATION_CLOSE, sends FIN packet, enters FIN_WAIT_1
Client 2 generates PACKET_ARRIVAL event
Client 2 calls APPLICATION_CLOSE event
At this point socket_state->flags.app_close == socket_state->flags.net_recv == 1
For Client 2, cascading if statements call handling of APPLICATION_CLOSE in state ESTABLISHED, then PACKET_ARRIVAL is later handled after Client 1 enters FIN_WAIT_1, violating TCP state rules
Proposed solutions:
Transpose the if clauses, so that flags.net_recv is considered first.
Add another conditional in the code, perhaps something like this:
if (socket_state->flags.app_close)
{
int packet_arrival = 0;
chilog(TRACE, "Event received: app_close");
socket_state->flags.app_close = 0;
if (socket_state->flags.net_recv)
{
packet_arrival = 1;
chilog(TRACE, "Event received: net_recv");
socket_state->flags.net_recv = 0;
}
pthread_mutex_unlock(&socket_state->lock_event);
if (packet_arrival)
{
chitcpd_dispatch_tcp(si, entry, PACKET_ARRIVAL);
}
chitcpd_dispatch_tcp(si, entry, APPLICATION_CLOSE);
}
Handling of APPLICATION_CLOSE condvar flag broadcasts in
tcp_thread.c
would overridePACKET_ARRIVAL
events, necessitating clunky handling of packets in event of APPLICATION_CLOSE.Scenario in which this would be a problem:
socket_state->flags.app_close == socket_state->flags.net_recv == 1
Proposed solutions:
if
clauses, so thatflags.net_recv
is considered first.@borjasotomayor
The text was updated successfully, but these errors were encountered: