mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 18:03:03 +01:00
This should fix #8215: Rare sporadic segfaults in test for core-6142 on windows.
This commit is contained in:
parent
3c88bb003f
commit
fceeaebdba
@ -108,10 +108,6 @@ inline ThreadId getThreadId()
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_POSIX_THREADS
|
||||
#define USE_FINI_SEM
|
||||
#endif
|
||||
|
||||
template <typename TA, void (*cleanup) (TA) = nullptr>
|
||||
class ThreadFinishSync
|
||||
{
|
||||
@ -119,12 +115,7 @@ public:
|
||||
typedef void ThreadRoutine(TA);
|
||||
|
||||
ThreadFinishSync(Firebird::MemoryPool& pool, ThreadRoutine* routine, int priority_arg = THREAD_medium)
|
||||
:
|
||||
#ifdef USE_FINI_SEM
|
||||
fini(pool),
|
||||
#else
|
||||
threadHandle(0),
|
||||
#endif
|
||||
: threadHandle(0),
|
||||
threadRoutine(routine),
|
||||
threadPriority(priority_arg),
|
||||
closing(false)
|
||||
@ -133,12 +124,7 @@ public:
|
||||
void run(TA arg)
|
||||
{
|
||||
threadArg = arg;
|
||||
|
||||
Thread::start(internalRun, this, threadPriority
|
||||
#ifndef USE_FINI_SEM
|
||||
, &threadHandle
|
||||
#endif
|
||||
);
|
||||
Thread::start(internalRun, this, threadPriority, &threadHandle);
|
||||
}
|
||||
|
||||
bool tryWait()
|
||||
@ -153,24 +139,15 @@ public:
|
||||
|
||||
void waitForCompletion()
|
||||
{
|
||||
#ifdef USE_FINI_SEM
|
||||
fini.enter();
|
||||
#else
|
||||
if (threadHandle)
|
||||
{
|
||||
Thread::waitForCompletion(threadHandle);
|
||||
threadHandle = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
#ifdef USE_FINI_SEM
|
||||
Firebird::Semaphore fini;
|
||||
#else
|
||||
Thread::Handle threadHandle;
|
||||
#endif
|
||||
|
||||
TA threadArg;
|
||||
ThreadRoutine* threadRoutine;
|
||||
int threadPriority;
|
||||
@ -193,17 +170,6 @@ private:
|
||||
threadArg->exceptionHandler(ex, threadRoutine);
|
||||
}
|
||||
|
||||
#ifdef USE_FINI_SEM
|
||||
try
|
||||
{
|
||||
fini.release();
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
threadArg->exceptionHandler(ex, threadRoutine);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cleanup)
|
||||
cleanup(threadArg);
|
||||
closing = true;
|
||||
|
Loading…
Reference in New Issue
Block a user