Skip to content

Commit

Permalink
fix broken gltest
Browse files Browse the repository at this point in the history
Order of deletion was changed, default behaviour became erroneous.
  • Loading branch information
klirichek committed Jun 29, 2023
1 parent 6128811 commit 1399e6f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/gtests/gtests_globalstate.cpp
Expand Up @@ -66,8 +66,8 @@ class Environment : public ::testing::Environment
auto iThreads = GetNumLogicalCPUs();
// iThreads = 1; // uncomment if want to run all coro tests in single thread
SetMaxChildrenThreads ( iThreads );
WipeGlobalSchedulerOnShutdownAndFork();
StartGlobalWorkPool();
WipeGlobalSchedulerOnShutdownAndFork();
#if _WIN32
// init WSA on Windows
WSADATA wsa_data;
Expand All @@ -85,6 +85,7 @@ class Environment : public ::testing::Environment
{
unlink ( g_sTmpfile );
unlink ( g_sMagickTmpfile );
StopGlobalWorkPool();
}
};

Expand Down
4 changes: 1 addition & 3 deletions src/searchd.cpp
Expand Up @@ -761,9 +761,7 @@ void Shutdown () REQUIRES ( MainThread ) NO_THREAD_SAFETY_ANALYSIS
Detached::ShutdownAllAlones();

SHUTINFO << "Shutdown main work pool ...";
auto pPool = GlobalWorkPool();
if ( pPool )
pPool->StopAll();
StopGlobalWorkPool();

SHUTINFO << "Remove local tables list ...";
g_pLocalIndexes.reset();
Expand Down
10 changes: 9 additions & 1 deletion src/threadutils.cpp
Expand Up @@ -1133,6 +1133,14 @@ void StartGlobalWorkPool ()
pPool = new ThreadPool_c ( g_iMaxChildrenThreads, "work" );
}

void StopGlobalWorkPool()
{
sphLogDebug ( "StopGlobalWorkPool" );
WorkerSharedPtr_t& pPool = GlobalPoolSingletone();
if ( pPool )
pPool->StopAll();
}

void SetMaxChildrenThreads ( int iThreads )
{
sphLogDebug ( "SetMaxChildrenThreads to %d", iThreads );
Expand Down Expand Up @@ -1276,7 +1284,7 @@ bool OperationsQueue_c::IsEmpty() const

namespace { // static

class IterationHandler_c : public Threads::details::SchedulerOperation_t
class IterationHandler_c : public Threads::details::SchedulerOperation_t
{
ThreadIteratorFN m_Handler;

Expand Down
1 change: 1 addition & 0 deletions src/threadutils.h
Expand Up @@ -264,6 +264,7 @@ namespace CrashLogger
Threads::Worker_i* GlobalWorkPool ();
void SetMaxChildrenThreads ( int iThreads );
void StartGlobalWorkPool ();
void StopGlobalWorkPool();

/// schedule stop of the global thread pool
void WipeGlobalSchedulerOnShutdownAndFork ();
Expand Down

0 comments on commit 1399e6f

Please sign in to comment.