mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Fix connection notification races. (#130)
Use a mutex on the connection state and one-shot all change notifications. Fixes #127.
This commit is contained in:
@@ -193,10 +193,7 @@ std::vector<ConnectionInfo> DispatcherBase::GetConnections() const {
|
||||
void DispatcherBase::NotifyConnections(
|
||||
ConnectionListenerCallback callback) const {
|
||||
std::lock_guard<std::mutex> lock(m_user_mutex);
|
||||
for (auto& conn : m_connections) {
|
||||
if (conn->state() != NetworkConnection::kActive) continue;
|
||||
m_notifier.NotifyConnection(true, conn->info(), callback);
|
||||
}
|
||||
for (const auto& conn : m_connections) conn->NotifyIfActive(callback);
|
||||
}
|
||||
|
||||
void DispatcherBase::DispatchThreadMain() {
|
||||
|
||||
Reference in New Issue
Block a user