From 490e383b55d0108cbee9b53e7e9cc90ad3c3f8f8 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 30 Nov 2023 10:51:25 +0100 Subject: WinIoThreadPool teardown cleaned up (#580) previously would not shut down the threadpool properly which would leave threads around. This was not a problem in practice for our usage since we keep the thread pool alive for the duration of the process but it's better to clean up properly. --- src/zenhttp/servers/iothreadpool.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/zenhttp/servers/iothreadpool.cpp') diff --git a/src/zenhttp/servers/iothreadpool.cpp b/src/zenhttp/servers/iothreadpool.cpp index da4b42e28..e941606e2 100644 --- a/src/zenhttp/servers/iothreadpool.cpp +++ b/src/zenhttp/servers/iothreadpool.cpp @@ -33,7 +33,12 @@ WinIoThreadPool::WinIoThreadPool(int InThreadCount, int InMaxThreadCount) WinIoThreadPool::~WinIoThreadPool() { + // this will wait for all callbacks to complete and tear down the `CreateThreadpoolIo` + // object and release all related objects + CloseThreadpoolCleanupGroupMembers(m_CleanupGroup, /* cancel pending callbacks */ TRUE, nullptr); + CloseThreadpoolCleanupGroup(m_CleanupGroup); CloseThreadpool(m_ThreadPool); + DestroyThreadpoolEnvironment(&m_CallbackEnvironment); } void -- cgit v1.2.3