Unlike std::net::TcpListener, tokio::net::TcpListener will internally accept TCP connections even when the application has stopped calling accept on the TcpListener. As such, connection attempts during a graceful shutdown will be accepted by tokio, but will not be processed; once the shutdown completes, the connections will be closed.
This PR drops the TcpListener before waiting for the shutdown to complete, so that new connection attempts during a shutdown are immediately refused, rather than them being accepted and then hanging until the shutdown completes.
Unlike
std::net::TcpListener
,tokio::net::TcpListener
will internally accept TCP connections even when the application has stopped calling accept on theTcpListener
. As such, connection attempts during a graceful shutdown will be accepted by tokio, but will not be processed; once the shutdown completes, the connections will be closed.This PR drops the
TcpListener
before waiting for the shutdown to complete, so that new connection attempts during a shutdown are immediately refused, rather than them being accepted and then hanging until the shutdown completes.