mirror of
https://github.com/minetest/minetest.git
synced 2024-09-12 00:26:50 +02:00
Fix synchronization issue at thread start
If a newly started thread immediately exits then m_running would immediately be set to false again and the caller would be stuck waiting for m_running to become true forever. Since a mutex for synchronizing startup already exists we can simply move the while loop into it. see also: #5134 which introduced m_start_finished_mutex
This commit is contained in:
parent
56a558baf8
commit
663c936428
@ -121,12 +121,12 @@ bool Thread::start()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow spawned thread to continue
|
||||
m_start_finished_mutex.unlock();
|
||||
|
||||
while (!m_running)
|
||||
sleep_ms(1);
|
||||
|
||||
// Allow spawned thread to continue
|
||||
m_start_finished_mutex.unlock();
|
||||
|
||||
m_joinable = true;
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user