diff options
-rw-r--r-- | src/server/shared/Threading/Threading.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/server/shared/Threading/Threading.cpp b/src/server/shared/Threading/Threading.cpp index bd96c359616..34a7bf8bb9d 100644 --- a/src/server/shared/Threading/Threading.cpp +++ b/src/server/shared/Threading/Threading.cpp @@ -62,7 +62,7 @@ ThreadPriority::ThreadPriority() //since we have only 7(seven) values in enum Priority //and 3 we know already (Idle, Normal, Realtime) so //we need to split each list [Idle...Normal] and [Normal...Realtime] - //into ¹ piesces + //into piecies const size_t _divider = 4; size_t _div = (norm_pos - min_pos) / _divider; if (_div == 0) @@ -130,10 +130,13 @@ bool Thread::start() if (m_task == 0 || m_iThreadId != 0) return false; + // incRef before spawing the thread, otherwise Thread::ThreadTask() might call decRef and delete m_task + m_task->incReference(); + bool res = (ACE_Thread::spawn(&Thread::ThreadTask, (void*)m_task, THREADFLAG, &m_iThreadId, &m_hThreadHandle) == 0); - if (res) - m_task->incReference(); + if (!res) + m_task->decReference(); return res; } |