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:
parent
494aeb199d
commit
8a2c8c58ca
1 changed files with 2 additions and 4 deletions
|
@ -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(th);
|
||||
|
||||
delete_thread(Threads.main()); // Must be the last one
|
||||
clear(); // Get rid of stale pointers
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue