Skip to content

Commit 901224e

Browse files
Synchronize changes from 1.6 branch [ci skip]
6ffa19f Addendum to 1dc9368 (Reverts only a part of itself)
2 parents a064676 + 6ffa19f commit 901224e

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

Server/mods/deathmatch/logic/CGame.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,6 @@ CGame::~CGame()
365365
// Stop async task scheduler
366366
SAFE_DELETE(m_pAsyncTaskScheduler);
367367

368-
// Shutdown thread pool before destroying resources to prevent tasks being enqueued during shutdown
369-
CThreadPool::getDefaultThreadPool().shutdown();
370-
371368
// Destroy our stuff
372369
SAFE_DELETE(m_pResourceManager);
373370

@@ -426,6 +423,7 @@ CGame::~CGame()
426423
SAFE_DELETE(m_pASE);
427424
SAFE_RELEASE(m_pHqComms);
428425
CSimControl::Shutdown();
426+
CThreadPool::getDefaultThreadPool().shutdown();
429427

430428
// Clear our global pointer
431429
g_pGame = NULL;

Shared/sdk/SharedUtil.ThreadPool.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,10 @@ namespace SharedUtil
103103

104104
m_exit = true;
105105

106-
// Discard all remaining tasks
106+
// Clear all remaining tasks (they will be destroyed automatically)
107107
while (!m_tasks.empty())
108108
{
109-
// Run each task with skip flag to clean up without executing
110-
auto task = std::move(m_tasks.front());
111-
m_tasks.pop(); // Important: Remove from queue to avoid infinite loop
112-
113-
// Execute cleanup outside the critical section to reduce lock contention
114-
lock.unlock();
115-
try
116-
{
117-
task(true); // Cleanup the shared_ptr
118-
}
119-
catch (...)
120-
{
121-
// Exceptions during cleanup indicate a serious bug (e.g., corrupted lambda)
122-
// We cannot propagate this exception as we're mid-shutdown with the lock released.
123-
// In debug builds, this should be logged/asserted.
124-
dassert(false && "Exception during thread pool task cleanup");
125-
}
126-
lock.lock();
109+
m_tasks.pop();
127110
}
128111
}
129112

0 commit comments

Comments
 (0)