mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpinet] Leak multicast handles during windows shutdown (#5550)
Destructing either of the multicast objects during process shutdown will result in a crash due to attempting to start a task on the non-existent thread pool. Solve this by just leaking all the handles upon destruction of the static multicast manager. This won't solve the case where the user statically allocates the object, but solves Java and C access, and most cases wouldn't be statically allocating the service announcer anyway in C++.
This commit is contained in:
@@ -10,3 +10,17 @@ MulticastHandleManager& wpi::GetMulticastManager() {
|
||||
static MulticastHandleManager manager;
|
||||
return manager;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
MulticastHandleManager::~MulticastHandleManager() {
|
||||
// Multicast handles cannot be safely destructed on windows during shutdown.
|
||||
// Just leak all handles.
|
||||
for (auto&& i : resolvers) {
|
||||
i.second.release();
|
||||
}
|
||||
|
||||
for (auto&& i : announcers) {
|
||||
i.second.release();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,9 @@ struct MulticastHandleManager {
|
||||
resolvers;
|
||||
wpi::DenseMap<size_t, std::unique_ptr<wpi::MulticastServiceAnnouncer>>
|
||||
announcers;
|
||||
#ifdef _WIN32
|
||||
~MulticastHandleManager();
|
||||
#endif
|
||||
};
|
||||
|
||||
MulticastHandleManager& GetMulticastManager();
|
||||
|
||||
Reference in New Issue
Block a user