* cleanly close the connection */
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
stream_session_reset_notify (&tc->connection);
- tc->state = TCP_STATE_CLOSED;
- TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc);
+ tcp_connection_set_state (tc, TCP_STATE_CLOSED);
break;
case TCP_STATE_CLOSE_WAIT:
case TCP_STATE_FIN_WAIT_1:
case TCP_STATE_LAST_ACK:
tcp_connection_timers_reset (tc);
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
- tc->state = TCP_STATE_CLOSED;
- TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc);
+ /* Make sure we mark the session as closed. In some states we may
+ * be still trying to send data */
+ session_stream_close_notify (&tc->connection);
+ tcp_connection_set_state (tc, TCP_STATE_CLOSED);
break;
case TCP_STATE_CLOSED:
break;
case TCP_STATE_SYN_RCVD:
tcp_connection_timers_reset (tc);
tcp_send_fin (tc);
- tc->state = TCP_STATE_FIN_WAIT_1;
+ tcp_connection_set_state (tc, TCP_STATE_FIN_WAIT_1);
tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_FINWAIT1_TIME);
break;
case TCP_STATE_ESTABLISHED:
tcp_send_fin (tc);
else
tc->flags |= TCP_CONN_FINPNDG;
- tc->state = TCP_STATE_FIN_WAIT_1;
+ tcp_connection_set_state (tc, TCP_STATE_FIN_WAIT_1);
/* Set a timer in case the peer stops responding. Otherwise the
* connection will be stuck here forever. */
tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_FINWAIT1_TIME);
{
tcp_send_fin (tc);
tcp_connection_timers_reset (tc);
- tc->state = TCP_STATE_LAST_ACK;
+ tcp_connection_set_state (tc, TCP_STATE_LAST_ACK);
tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
}
else
TCP_DBG ("state: %u", tc->state);
}
- TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc);
-
/* If in CLOSED and WAITCLOSE timer is not set, delete connection.
* But instead of doing it now wait until next dispatch cycle to give
* the session layer a chance to clear unhandled events */
{
case TCP_STATE_CLOSE_WAIT:
tcp_connection_timers_reset (tc);
+ session_stream_close_notify (&tc->connection);
if (!(tc->flags & TCP_CONN_FINPNDG))
{
tcp_connection_timers_reset (tc);
tcp_connection_set_state (tc, TCP_STATE_CLOSED);
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
+ session_stream_close_notify (&tc->connection);
break;
default:
tcp_connection_del (tc);