8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 17:23:03 +01:00

This should fix #8215: Rare sporadic segfaults in test for core-6142 on windows.

This commit is contained in:
AlexPeshkoff 2024-08-16 17:13:43 +03:00
parent 3c88bb003f
commit fceeaebdba

View File

@ -108,10 +108,6 @@ inline ThreadId getThreadId()
} }
#ifndef USE_POSIX_THREADS
#define USE_FINI_SEM
#endif
template <typename TA, void (*cleanup) (TA) = nullptr> template <typename TA, void (*cleanup) (TA) = nullptr>
class ThreadFinishSync class ThreadFinishSync
{ {
@ -119,12 +115,7 @@ public:
typedef void ThreadRoutine(TA); typedef void ThreadRoutine(TA);
ThreadFinishSync(Firebird::MemoryPool& pool, ThreadRoutine* routine, int priority_arg = THREAD_medium) ThreadFinishSync(Firebird::MemoryPool& pool, ThreadRoutine* routine, int priority_arg = THREAD_medium)
: : threadHandle(0),
#ifdef USE_FINI_SEM
fini(pool),
#else
threadHandle(0),
#endif
threadRoutine(routine), threadRoutine(routine),
threadPriority(priority_arg), threadPriority(priority_arg),
closing(false) closing(false)
@ -133,12 +124,7 @@ public:
void run(TA arg) void run(TA arg)
{ {
threadArg = arg; threadArg = arg;
Thread::start(internalRun, this, threadPriority, &threadHandle);
Thread::start(internalRun, this, threadPriority
#ifndef USE_FINI_SEM
, &threadHandle
#endif
);
} }
bool tryWait() bool tryWait()
@ -153,24 +139,15 @@ public:
void waitForCompletion() void waitForCompletion()
{ {
#ifdef USE_FINI_SEM
fini.enter();
#else
if (threadHandle) if (threadHandle)
{ {
Thread::waitForCompletion(threadHandle); Thread::waitForCompletion(threadHandle);
threadHandle = 0; threadHandle = 0;
} }
#endif
} }
private: private:
#ifdef USE_FINI_SEM
Firebird::Semaphore fini;
#else
Thread::Handle threadHandle; Thread::Handle threadHandle;
#endif
TA threadArg; TA threadArg;
ThreadRoutine* threadRoutine; ThreadRoutine* threadRoutine;
int threadPriority; int threadPriority;
@ -193,17 +170,6 @@ private:
threadArg->exceptionHandler(ex, threadRoutine); threadArg->exceptionHandler(ex, threadRoutine);
} }
#ifdef USE_FINI_SEM
try
{
fini.release();
}
catch (const Firebird::Exception& ex)
{
threadArg->exceptionHandler(ex, threadRoutine);
}
#endif
if (cleanup) if (cleanup)
cleanup(threadArg); cleanup(threadArg);
closing = true; closing = true;