From 898664ea290e779bf714d8291aabad87beb1dc23 Mon Sep 17 00:00:00 2001 From: Dmitri Tikhonov Date: Fri, 17 Apr 2020 12:06:48 -0400 Subject: [PATCH] Fix: place connections on tickable queue when sending is reenabled Because connections' tickability depends on the ability of the engine to send packets (ENPUB_CAN_SEND is checked), this property should be recalculated when sending is reenabled in the engine via lsquic_engine_send_unsent_packets() --- src/liblsquic/lsquic_engine.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/liblsquic/lsquic_engine.c b/src/liblsquic/lsquic_engine.c index eabc925..41a7a6c 100644 --- a/src/liblsquic/lsquic_engine.c +++ b/src/liblsquic/lsquic_engine.c @@ -2445,6 +2445,32 @@ reset_deadline (lsquic_engine_t *engine, lsquic_time_t now) } +static void +check_tickable_conns_again (struct lsquic_engine *engine) +{ + struct lsquic_hash_elem *el; + struct lsquic_conn *conn; + unsigned count; + + count = 0; + for (el = lsquic_hash_first(engine->conns_hash); el; + el = lsquic_hash_next(engine->conns_hash)) + { + conn = lsquic_hashelem_getdata(el); + if (!(conn->cn_flags & LSCONN_TICKABLE) + && conn->cn_if->ci_is_tickable(conn)) + { + lsquic_mh_insert(&engine->conns_tickable, conn, + conn->cn_last_ticked); + engine_incref_conn(conn, LSCONN_TICKABLE); + ++count; + } + } + LSQ_DEBUG("%u connection%s tickable again after sending has been " + "re-enabled", count, count == 1 ? " is" : "s are"); +} + + void lsquic_engine_send_unsent_packets (lsquic_engine_t *engine) { @@ -2462,6 +2488,7 @@ lsquic_engine_send_unsent_packets (lsquic_engine_t *engine) LSQ_DEBUG("can send again"); EV_LOG_GENERIC_EVENT("can send again"); engine->pub.enp_flags |= ENPUB_CAN_SEND; + check_tickable_conns_again(engine); } send_packets_out(engine, &ticked_conns, &closed_conns);