[ntcore] NetworkClient: Add IsLoopClosing() guard in deferred disconnect timer (#8936)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Vasista Vovveti
2026-06-05 15:01:44 -07:00
committed by GitHub
parent e085c3e8b3
commit d941be905e

View File

@@ -285,6 +285,13 @@ void NetworkClient::WsConnected(wpi::net::WebSocket& ws, uv::Tcp& tcp,
uv::Timer::SingleShot( uv::Timer::SingleShot(
m_loop, uv::Timer::Time{0}, m_loop, uv::Timer::Time{0},
[this, reason = std::string{reason}, keepws = ws.shared_from_this()] { [this, reason = std::string{reason}, keepws = ws.shared_from_this()] {
// Check that the loop is not shutting down. keepws->GetStream()
// would dereference the underlying uv::Tcp which may have been
// destroyed after Handle::Close() released its self-reference.
// m_loop is safe to access as long as `this` is alive.
if (m_loop.IsClosing()) {
return;
}
DoDisconnect(reason); DoDisconnect(reason);
}); });
} }