From 3550f12543d851fcfe5b477dd0569839c467d3e8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 11 Jan 2022 00:49:00 +0100 Subject: [PATCH] Kernel: Make ListedRefCounted::unref() call optional list removal helper Look for remove_from_secondary_lists() and call it on the ref-counting target if present *while the lock is held*. This allows listed-ref-counted objects to be present in multiple lists and still have synchronized removal on final unref. --- Kernel/Library/ListedRefCounted.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Kernel/Library/ListedRefCounted.h b/Kernel/Library/ListedRefCounted.h index f461779c00..154d3de60e 100644 --- a/Kernel/Library/ListedRefCounted.h +++ b/Kernel/Library/ListedRefCounted.h @@ -34,6 +34,8 @@ public: if constexpr (requires { that->revoke_weak_ptrs(); }) { that->revoke_weak_ptrs(); } + if constexpr (requires { that->remove_from_secondary_lists(); }) + that->remove_from_secondary_lists(); } return new_ref_count; };