[wpinet] uv: Stop creating handles when closing loop (#5102)

This prevents EventLoopRunner::Stop() from hanging in the case when
new handles are created after the async walk closes all the handles.
This commit is contained in:
Peter Johnson
2023-02-16 22:49:14 -08:00
committed by GitHub
parent 805c837a42
commit 8068369542
29 changed files with 300 additions and 82 deletions

View File

@@ -24,6 +24,9 @@ ParallelTcpConnector::ParallelTcpConnector(
m_reconnectRate{reconnectRate},
m_connected{std::move(connected)},
m_reconnectTimer{uv::Timer::Create(loop)} {
if (!m_reconnectTimer) {
return;
}
m_reconnectTimer->timeout.connect([this] {
if (!IsConnected()) {
WPI_DEBUG1(m_logger, "timed out, reconnecting");
@@ -86,6 +89,9 @@ void ParallelTcpConnector::Connect() {
// kick off parallel connection attempts
for (auto ai = &addrinfo; ai; ai = ai->ai_next) {
auto tcp = uv::Tcp::Create(m_loop);
if (!tcp) {
continue;
}
m_attempts.emplace_back(tcp);
auto connreq = std::make_shared<uv::TcpConnectReq>();