1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Better fix of crash bug

Crash is due to slave thread accessing main thread
data while exiting.

Fix it in the proper way makeing slave threads
independent from main state.

No functional change.
This commit is contained in:
Marco Costalba 2015-10-08 16:45:21 +02:00
parent 494aeb199d
commit 8a2c8c58ca

View file

@ -123,7 +123,7 @@ void Thread::idle_loop() {
{
std::unique_lock<Mutex> lk(mutex);
while (!Threads.main()->thinking && !exit)
while (!searching && !exit)
sleepCondition.wait(lk);
lk.unlock();
@ -190,10 +190,8 @@ void ThreadPool::exit() {
timer = nullptr;
for (Thread* th : *this)
if (th != Threads.main())
delete_thread(th);
delete_thread(Threads.main()); // Must be the last one
clear(); // Get rid of stale pointers
}