[kernel] Fix threads and procs never deleting

A check was added in scheduler::prune() which defers deleting threads
and processes if they're the current ones. However, they were still
getting removed from the block list, so they were being leaked.
This commit is contained in:
2020-09-23 00:15:23 -07:00
parent 113d14c440
commit 41eac2764a

View File

@@ -238,16 +238,22 @@ void scheduler::prune(uint64_t now)
if (!exited && !ready)
continue;
m_blocked.remove(remove);
if (exited) {
// If the current thread has exited, wait until the next call
// to prune() to delete it, because we may be deleting our current
// page tables
if (current) continue;
m_blocked.remove(remove);
process &p = th->parent();
// If the current thread has exited, wait until the next call
// to prune() to delete it.
// thread_exited deletes the thread, and returns true if the process
// should also now be deleted
if(!current && p.thread_exited(th))
delete &p;
} else {
m_blocked.remove(remove);
log::debug(logs::task, "Prune: readying unblocked thread %llx", th->koid());
m_runlists[remove->priority].push_back(remove);
}