From bf685cdf2e311bc47c131369fdaf3ca4b64416fe Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 1 Nov 2014 16:32:04 +0100 Subject: [PATCH] kernel: Fix missing reference release in CreateThreadEvent. CreateThreadEvent::DoDPC() missed a reference release to balance the acquired reference before queuing the DPC, resulting in the CreateThreadEvent objects being leaked. This also removes the destructor that tried to cancel the DPC. Since the class is reference counted and only destroyed when the DPC has run and released the last reference, this didn't make much sense. --- headers/private/kernel/UserEvent.h | 2 -- src/system/kernel/UserEvent.cpp | 9 ++------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/headers/private/kernel/UserEvent.h b/headers/private/kernel/UserEvent.h index 081ff9db25..5a7e5c2302 100644 --- a/headers/private/kernel/UserEvent.h +++ b/headers/private/kernel/UserEvent.h @@ -86,8 +86,6 @@ private: struct CreateThreadEvent : UserEvent, private DPCCallback { - ~CreateThreadEvent(); - static CreateThreadEvent* Create( const ThreadCreationAttributes& attributes); diff --git a/src/system/kernel/UserEvent.cpp b/src/system/kernel/UserEvent.cpp index 2cff40cfb4..6e51a06d2e 100644 --- a/src/system/kernel/UserEvent.cpp +++ b/src/system/kernel/UserEvent.cpp @@ -251,13 +251,6 @@ CreateThreadEvent::CreateThreadEvent(const ThreadCreationAttributes& attributes) } -CreateThreadEvent::~CreateThreadEvent() -{ - // cancel the DPC to be on the safe side - DPCQueue::DefaultQueue(B_NORMAL_PRIORITY)->Cancel(this); -} - - /*static*/ CreateThreadEvent* CreateThreadEvent::Create(const ThreadCreationAttributes& attributes) { @@ -289,4 +282,6 @@ CreateThreadEvent::DoDPC(DPCQueue* queue) thread_id threadID = thread_create_thread(fCreationAttributes, false); if (threadID >= 0) resume_thread(threadID); + + ReleaseReference(); }