|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53388 - in trunk/libs/thread: src/pthread src/win32 test
From: anthony_at_[hidden]
Date: 2009-05-29 07:05:01
Author: anthonyw
Date: 2009-05-29 07:05:01 EDT (Fri, 29 May 2009)
New Revision: 53388
URL: http://svn.boost.org/trac/boost/changeset/53388
Log:
TSS cleanup not called for NULL data
Text files modified:
trunk/libs/thread/src/pthread/thread.cpp | 2 +-
trunk/libs/thread/src/win32/thread.cpp | 2 +-
trunk/libs/thread/test/test_tss.cpp | 14 ++++++++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp (original)
+++ trunk/libs/thread/src/pthread/thread.cpp 2009-05-29 07:05:01 EDT (Fri, 29 May 2009)
@@ -578,7 +578,7 @@
{
if(tss_data_node* const current_node=find_tss_data(key))
{
- if(cleanup_existing && current_node->func)
+ if(cleanup_existing && current_node->func && current_node->value)
{
(*current_node->func)(current_node->value);
}
Modified: trunk/libs/thread/src/win32/thread.cpp
==============================================================================
--- trunk/libs/thread/src/win32/thread.cpp (original)
+++ trunk/libs/thread/src/win32/thread.cpp 2009-05-29 07:05:01 EDT (Fri, 29 May 2009)
@@ -561,7 +561,7 @@
{
if(tss_data_node* const current_node=find_tss_data(key))
{
- if(cleanup_existing && current_node->func.get())
+ if(cleanup_existing && current_node->func.get() && current_node->value)
{
(*current_node->func)(current_node->value);
}
Modified: trunk/libs/thread/test/test_tss.cpp
==============================================================================
--- trunk/libs/thread/test/test_tss.cpp (original)
+++ trunk/libs/thread/test/test_tss.cpp 2009-05-29 07:05:01 EDT (Fri, 29 May 2009)
@@ -329,6 +329,19 @@
BOOST_CHECK(!tss_cleanup_called);
}
+void test_tss_cleanup_not_called_for_null_pointer()
+{
+ boost::thread_specific_ptr<Dummy> local_tss(tss_custom_cleanup);
+ local_tss.reset(new Dummy);
+ tss_cleanup_called=false;
+ local_tss.reset(0);
+ BOOST_CHECK(tss_cleanup_called);
+ tss_cleanup_called=false;
+ local_tss.reset(new Dummy);
+ BOOST_CHECK(!tss_cleanup_called);
+}
+
+
boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
{
@@ -340,6 +353,7 @@
test->add(BOOST_TEST_CASE(test_tss_does_no_cleanup_after_release));
test->add(BOOST_TEST_CASE(test_tss_does_no_cleanup_with_null_cleanup_function));
test->add(BOOST_TEST_CASE(test_tss_does_not_call_cleanup_after_ptr_destroyed));
+ test->add(BOOST_TEST_CASE(test_tss_cleanup_not_called_for_null_pointer));
return test;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk