[tyndur-devel] [PATCH v2] tcpip: Verbindung nicht doppelt schliessen
Kevin Wolf ·
! tcpip: Wenn die Verbindung durch fclose geschlossen werden soll, die Gegenstelle aber bereits ihrerseits ein FIN geschickt hat, brauchen wir nicht nochmal ein neues FIN schicken und in einen Timeout rennen. Signed-off-by: Kevin Wolf <kevin at tyndur.org> --- src/modules/tcpip/tcp.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modules/tcpip/tcp.c b/src/modules/tcpip/tcp.c index 60fb896..92378dc 100644 --- a/src/modules/tcpip/tcp.c +++ b/src/modules/tcpip/tcp.c @@ -270,19 +270,26 @@ void tcp_close_connection(struct tcp_connection* conn) { uint64_t timeout; - DEBUG_MSG("tcp_send_fin_ack"); - conn->status = TCPS_WAIT_FOR_FIN_ACK; - tcp_send_fin(conn, FALSE); + if (conn->status == TCPS_WAIT_FOR_LAST_ACK + || conn->status == TCPS_WAIT_FOR_FIN_ACK + || conn->status == TCPS_CLOSED) + { + DEBUG_MSG("Verbindung ist schon geschlossen"); + } else { + DEBUG_MSG("tcp_send_fin_ack"); + conn->status = TCPS_WAIT_FOR_FIN_ACK; + tcp_send_fin(conn, FALSE); + } timeout = get_tick_count() + 9 * 1000000; timer_register(do_nothing, 10 * 1000000); - while ((conn->status == TCPS_WAIT_FOR_FIN_ACK) + while ((conn->status != TCPS_CLOSED) && (get_tick_count() < timeout)) { wait_for_rpc(); } - if (conn->status == TCPS_WAIT_FOR_FIN_ACK) { + if (conn->status != TCPS_CLOSED) { tcp_send_reset(conn); DEBUG_MSG("Timeout beim Schliessen der Verbindung"); } -- 1.6.0.2
Antworten
- [tyndur-devel] [PATCH v2] tcpip: Verbindung nicht doppelt schliessen · Antoine Kaufmann