From 31a4736c76b250016f91b6cd7435fe354dc0a1a6 Mon Sep 17 00:00:00 2001 From: Davis King Date: Thu, 5 Feb 2009 03:09:58 +0000 Subject: [PATCH] Changed code to avoid a potential race condition during program termination. --HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402865 --- dlib/threads/threads_kernel_shared.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dlib/threads/threads_kernel_shared.cpp b/dlib/threads/threads_kernel_shared.cpp index 5adc33088..bc4b272bf 100644 --- a/dlib/threads/threads_kernel_shared.cpp +++ b/dlib/threads/threads_kernel_shared.cpp @@ -120,12 +120,11 @@ namespace dlib reg.m.lock(); const thread_id_type id = get_thread_id(); thread_id_type id_copy; - unsigned long count = reg.reg.count(id); member_function_pointer<>::kernel_1a mfp; // Remove all the member function pointers for this thread from the tree // and call them. - for (unsigned long i = 0; i < count; ++i) + while (reg.reg[id] != 0) { reg.reg.remove(id,id_copy,mfp); reg.m.unlock();