From 0c7fe5232e523232ab6992c53eef7fd823370825 Mon Sep 17 00:00:00 2001 From: Lei Shi Date: Thu, 1 Jun 2017 16:26:45 -0700 Subject: [PATCH] fix handle leak for recycler concurrent thread --- lib/Common/Memory/Recycler.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/Common/Memory/Recycler.cpp b/lib/Common/Memory/Recycler.cpp index 87073479a47..edbe4c7c0db 100644 --- a/lib/Common/Memory/Recycler.cpp +++ b/lib/Common/Memory/Recycler.cpp @@ -4613,7 +4613,11 @@ Recycler::FinalizeConcurrent(bool restoreState) } this->threadService = nullptr; - this->concurrentThread = nullptr; + if (concurrentThread != NULL) + { + CloseHandle(concurrentThread); + this->concurrentThread = nullptr; + } } bool @@ -4745,10 +4749,6 @@ Recycler::ShutdownThread() Assert(concurrentThread != NULL || threadService->HasCallback()); FinalizeConcurrent(false); - if (concurrentThread) - { - CloseHandle(concurrentThread); - } } } @@ -4760,10 +4760,6 @@ Recycler::DisableConcurrent() Assert(concurrentThread != NULL || threadService->HasCallback()); FinalizeConcurrent(true); - if (concurrentThread) - { - CloseHandle(concurrentThread); - } this->collectionState = CollectionStateNotCollecting; } }