[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:
Thad House
2023-08-18 19:15:16 -07:00
committed by GitHub
parent f9e2757d8f
commit 7a2d336d52
2 changed files with 17 additions and 0 deletions

View File

@@ -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

View File

@@ -20,6 +20,9 @@ struct MulticastHandleManager {
resolvers;
wpi::DenseMap<size_t, std::unique_ptr<wpi::MulticastServiceAnnouncer>>
announcers;
#ifdef _WIN32
~MulticastHandleManager();
#endif
};
MulticastHandleManager& GetMulticastManager();