Kernel/ProcFS: Clean dead processes properly

Now we use WeakPtrs to break Ref-counting cycle. Also, we call the
prepare_for_deletion method to ensure deleted objects are ready for
deletion. This is necessary to ensure we don't keep dead processes,
which would become zombies.

In addition to that, add some debug prints to aid debug in the future.
This commit is contained in:
Liav A 2021-07-01 19:18:38 +03:00 committed by Andreas Kling
commit 3344f91fc4
Notes: sideshowbarker 2024-07-18 11:08:13 +09:00
6 changed files with 103 additions and 43 deletions

View file

@ -144,9 +144,11 @@ KResultOr<size_t> ProcFSUSBBusFolder::entries_count() const
KResult ProcFSUSBBusFolder::traverse_as_directory(unsigned fsid, Function<bool(const FS::DirectoryEntryView&)> callback) const
{
ScopedSpinLock lock(m_lock);
VERIFY(m_parent_folder);
auto parent_folder = m_parent_folder.strong_ref();
// Note: if the parent folder is null, it means something bad happened as this should not happen for the USB folder.
VERIFY(parent_folder);
callback({ ".", { fsid, component_index() }, 0 });
callback({ "..", { fsid, m_parent_folder->component_index() }, 0 });
callback({ "..", { fsid, parent_folder->component_index() }, 0 });
for (auto& device_node : m_device_nodes) {
InodeIdentifier identifier = { fsid, device_node.component_index() };