aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-12-04 05:16:22 -0500
committerGitHub <[email protected]>2023-12-04 11:16:22 +0100
commitaeecf717fee464ac2b9700e571d19c0c51794d7b (patch)
treec6b3abb9edca18d7b43b59b726b01245b26ba6ba
parentuse 32 bit offset and size in BlockStoreLocation (#581) (diff)
downloadzen-aeecf717fee464ac2b9700e571d19c0c51794d7b.tar.xz
zen-aeecf717fee464ac2b9700e571d19c0c51794d7b.zip
safe threadpool shutdown (#584)
* shut down thread pools earlier to worker threads has a chance to terminate before main thread atexit
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/zenserver/zenserver.cpp3
-rw-r--r--src/zenutil/workerpools.cpp6
3 files changed, 10 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d44bb2ec..b28525e7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
- Bugfix: Make sure we can override flags to "false" when running `zen gc` commmand
- `smallobjects`, `skipcid`, `skipdelete`, `verbose`
- Bugfix: fixed file log timestamp format so the milliseconds are appended after the time not the date
+- Bugfix: Shut down thread pools earlier so worker threads have a chance to terminate before main thread calls `atexit()`
- Improvement: The frontend html content is no longer appended at the end of the executable which prevented signing, instead it is compiled in from the `/src/zenserver/frontend/html.zip` archive
- Improvement: MacOS now does ad-hoc code signing by default when issuing `xmake bundle`, signing with proper cert is done on CI builds
- Improvement: Updated branding to be consistent with current working name ("Unreal Zen Storage Server" etc)
@@ -24,6 +25,7 @@
- Improvement: GCv2: Exit as soon as no more unreferenced items are left
- Improvement: Reduce memory usage in GC and diskbucket flush
+
## 0.2.35
- Bugfix: Fix timeout calculation for semtimedop call
- Bugfix: Fix NameEvent test to avoid race condition
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 2430267c1..f663417fb 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -643,6 +643,8 @@ ZenServer::Cleanup()
Flush();
+ ShutdownWorkerPools();
+
m_AdminService.reset();
m_VfsService.reset();
m_ObjStoreService.reset();
@@ -660,7 +662,6 @@ ZenServer::Cleanup()
m_AuthMgr.reset();
m_Http = {};
m_JobQueue.reset();
- ShutdownWorkerPools();
}
catch (std::exception& Ex)
{
diff --git a/src/zenutil/workerpools.cpp b/src/zenutil/workerpools.cpp
index b511b0c5c..3ae302064 100644
--- a/src/zenutil/workerpools.cpp
+++ b/src/zenutil/workerpools.cpp
@@ -14,6 +14,8 @@ namespace {
const int LargeWorkerThreadPoolTreadCount = gsl::narrow<int>(std::thread::hardware_concurrency());
const int SmallWorkerThreadPoolTreadCount = gsl::narrow<int>(Max((std::thread::hardware_concurrency() / 4u), 1u));
+ static bool IsShutDown = false;
+
RwLock PoolLock;
std::unique_ptr<WorkerThreadPool> LargeWorkerPool;
@@ -32,6 +34,7 @@ GetLargeWorkerPool()
}
}
RwLock::ExclusiveLockScope _(PoolLock);
+ ZEN_ASSERT(!IsShutDown);
if (LargeWorkerPool)
{
return *LargeWorkerPool;
@@ -51,6 +54,7 @@ GetSmallWorkerPool()
}
}
RwLock::ExclusiveLockScope _(PoolLock);
+ ZEN_ASSERT(!IsShutDown);
if (SmallWorkerPool)
{
return *SmallWorkerPool;
@@ -70,6 +74,7 @@ GetSyncWorkerPool()
}
}
RwLock::ExclusiveLockScope _(PoolLock);
+ ZEN_ASSERT(!IsShutDown);
if (SyncWorkerPool)
{
return *SyncWorkerPool;
@@ -82,6 +87,7 @@ void
ShutdownWorkerPools()
{
RwLock::ExclusiveLockScope _(PoolLock);
+ IsShutDown = true;
LargeWorkerPool.reset();
SmallWorkerPool.reset();
SyncWorkerPool.reset();