Fix: connection may not be closed timely when CONNECTION_CLOSE frame in (#284)

* Fix: connection may not be closed timely when CONNECTION_CLOSE frame in

* Simplify TICK_CLOSE logic

Co-authored-by: wangfuyu <ivanfywang@gmail.com>
This commit is contained in:
wangfuyu 2021-05-31 23:24:52 +08:00 committed by GitHub
parent 077ef87880
commit 3d35ba155f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View file

@ -3499,7 +3499,7 @@ full_conn_ci_tick (lsquic_conn_t *lconn, lsquic_time_t now)
* more than 1 packet over CWND.
*/
tick |= TICK_SEND;
goto end;
goto end_write;
}
/* Try to fit any of the following three frames -- STOP_WAITING,
@ -3587,7 +3587,6 @@ full_conn_ci_tick (lsquic_conn_t *lconn, lsquic_time_t now)
skip_write:
if ((conn->fc_flags & FC_CLOSING) && conn_ok_to_close(conn))
{
RETURN_IF_OUT_OF_PACKETS();
LSQ_DEBUG("connection is OK to close");
/* This is normal termination sequence.
*
@ -3595,15 +3594,16 @@ full_conn_ci_tick (lsquic_conn_t *lconn, lsquic_time_t now)
* packets scheduled to send, or silent close flag is not set.
*/
conn->fc_flags |= FC_TICK_CLOSE;
tick |= TICK_CLOSE;
if ((conn->fc_flags & FC_RECV_CLOSE) ||
0 != lsquic_send_ctl_n_scheduled(&conn->fc_send_ctl) ||
!conn->fc_settings->es_silent_close)
{
RETURN_IF_OUT_OF_PACKETS();
generate_connection_close_packet(conn);
tick |= TICK_SEND|TICK_CLOSE;
tick |= TICK_SEND;
}
else
tick |= TICK_CLOSE;
goto end;
}

View file

@ -8248,7 +8248,7 @@ ietf_full_conn_ci_tick (struct lsquic_conn *lconn, lsquic_time_t now)
* than 1 packet over CWND.
*/
tick |= TICK_SEND;
goto end;
goto end_write;
}
/* Try to fit MAX_DATA before checking if we have run out of room.
@ -8344,6 +8344,7 @@ ietf_full_conn_ci_tick (struct lsquic_conn *lconn, lsquic_time_t now)
{
LSQ_DEBUG("connection is OK to close");
conn->ifc_flags |= IFC_TICK_CLOSE;
tick |= TICK_CLOSE;
if (!(conn->ifc_mflags & MF_CONN_CLOSE_PACK)
/* Generate CONNECTION_CLOSE frame if:
* ... this is a client and handshake was successful;
@ -8368,10 +8369,9 @@ ietf_full_conn_ci_tick (struct lsquic_conn *lconn, lsquic_time_t now)
{
RETURN_IF_OUT_OF_PACKETS();
generate_connection_close_packet(conn);
tick |= TICK_SEND|TICK_CLOSE;
tick |= TICK_SEND;
}
else
tick |= TICK_CLOSE;
goto end;
}