From 73121eda9d015ac2857f6ee6f79b71e8f6573297 Mon Sep 17 00:00:00 2001 From: Anthony Williams Date: Fri, 12 Nov 2010 09:11:22 +0000 Subject: [PATCH] Better fix for #4736 --- ensure we have tried to allocate TLS value before complaining that it's not there, especially in native threads [SVN r66518] --- src/win32/thread.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index e6bf20a4..05c7a6c9 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -58,6 +58,8 @@ namespace boost boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); if(current_thread_tls_key) BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data)); + else + boost::throw_exception(thread_resource_error()); } #ifdef BOOST_NO_THREADEX @@ -222,15 +224,19 @@ namespace boost void make_external_thread_data() { externally_launched_thread* me=detail::heap_new(); - set_current_thread_data(me); + try + { + set_current_thread_data(me); + } + catch(...) + { + detail::heap_delete(me); + throw; + } } detail::thread_data_base* get_or_make_current_thread_data() { - if(!current_thread_tls_key) - { - throw thread_resource_error(); - } detail::thread_data_base* current_thread_data(get_current_thread_data()); if(!current_thread_data) {