From 684a219e39bd2ee15876f506fd8c1b19cec4d228 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 15 Sep 2021 23:07:46 +0900 Subject: [PATCH] nghttpx: Tweak close wait handling --- src/shrpx_quic_connection_handler.cc | 38 ++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/shrpx_quic_connection_handler.cc b/src/shrpx_quic_connection_handler.cc index 38acdf31..005c216d 100644 --- a/src/shrpx_quic_connection_handler.cc +++ b/src/shrpx_quic_connection_handler.cc @@ -93,13 +93,34 @@ int QUICConnectionHandler::handle_packet(const UpstreamAddr *faddr, auto &quicconf = config->quic; auto it = connections_.find(dcid_key); - if ((data[0] & 0x80) && it == std::end(connections_)) { - if (generate_quic_hashed_connection_id(dcid_key, remote_addr, local_addr, - dcid_key) != 0) { + if (it == std::end(connections_)) { + auto cwit = close_waits_.find(dcid_key); + if (cwit != std::end(close_waits_)) { + auto cw = (*cwit).second; + + cw->handle_packet(faddr, remote_addr, local_addr, data, datalen); + return 0; } - it = connections_.find(dcid_key); + if (data[0] & 0x80) { + if (generate_quic_hashed_connection_id(dcid_key, remote_addr, local_addr, + dcid_key) != 0) { + return 0; + } + + it = connections_.find(dcid_key); + if (it == std::end(connections_)) { + auto cwit = close_waits_.find(dcid_key); + if (cwit != std::end(close_waits_)) { + auto cw = (*cwit).second; + + cw->handle_packet(faddr, remote_addr, local_addr, data, datalen); + + return 0; + } + } + } } if (it == std::end(connections_)) { @@ -129,15 +150,6 @@ int QUICConnectionHandler::handle_packet(const UpstreamAddr *faddr, } } - auto it = close_waits_.find(dcid_key); - if (it != std::end(close_waits_)) { - auto cw = (*it).second; - - cw->handle_packet(faddr, remote_addr, local_addr, data, datalen); - - return 0; - } - // new connection auto &upstreamconf = config->conn.upstream;