From 20cbb25cd104c029b99d10a8c01cc18aa0d0b9d6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 25 Mar 2018 12:13:50 +0100 Subject: [PATCH] Added check if thraeding is running before executing start thread. --- src/OpenThreads/pthreads/PThread.cpp | 8 ++++++-- src/OpenThreads/win32/Win32Thread.cpp | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/OpenThreads/pthreads/PThread.cpp b/src/OpenThreads/pthreads/PThread.cpp index 3bec4ffbc..965514a23 100644 --- a/src/OpenThreads/pthreads/PThread.cpp +++ b/src/OpenThreads/pthreads/PThread.cpp @@ -638,6 +638,12 @@ bool Thread::isRunning() // int Thread::start() { + PThreadPrivateData *pd = static_cast (_prvData); + if (pd->isRunning()) + { + return 0; + } + int status; pthread_attr_t thread_attr; @@ -647,8 +653,6 @@ int Thread::start() { return status; } - PThreadPrivateData *pd = static_cast (_prvData); - //------------------------------------------------------------------------- // Set the stack size if requested, but not less than a platform reasonable // value. diff --git a/src/OpenThreads/win32/Win32Thread.cpp b/src/OpenThreads/win32/Win32Thread.cpp index 9ade67eb7..3444b6b2b 100644 --- a/src/OpenThreads/win32/Win32Thread.cpp +++ b/src/OpenThreads/win32/Win32Thread.cpp @@ -336,6 +336,11 @@ bool Thread::isRunning() { int Thread::start() { Win32ThreadPrivateData *pd = static_cast (_prvData); + if (pd->isRunning) + { + return 0; + } + //------------------------------------------------------------------------- // Prohibit the stack size from being changed. // (bb 5/13/2005) it actually doesn't matter.