mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[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:
@@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user