mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 18:08:12 +00:00
Kernel: Don't hold thread list lock while invoking ~Thread()
There is no need for this, and it can cause deadlocks if ~Thread() ends up doing something else that requires a lock (e.g ~Process())
This commit is contained in:
parent
29a58459ab
commit
c1c12497b5
1 changed files with 5 additions and 2 deletions
|
@ -39,13 +39,16 @@ SpinLockProtectedValue<Thread::GlobalList>& Thread::all_threads()
|
|||
|
||||
bool Thread::unref() const
|
||||
{
|
||||
return all_threads().with([&](auto&) {
|
||||
bool did_hit_zero = all_threads().with([&](auto&) {
|
||||
if (deref_base())
|
||||
return false;
|
||||
m_global_thread_list_node.remove();
|
||||
delete this;
|
||||
return true;
|
||||
});
|
||||
|
||||
if (did_hit_zero)
|
||||
delete this;
|
||||
return did_hit_zero;
|
||||
}
|
||||
|
||||
KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> process)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue