Boost logo

Boost-Commit :

From: anthony_at_[hidden]
Date: 2008-03-17 09:46:20


Author: anthonyw
Date: 2008-03-17 09:46:19 EDT (Mon, 17 Mar 2008)
New Revision: 43673
URL: http://svn.boost.org/trac/boost/changeset/43673

Log:
Test and fix for bug #1693 to ensure thread_specific_ptr::release works as desired imported from trunk changeset 43666
Text files modified:
   branches/release/boost/thread/pthread/tss.hpp | 2 +-
   branches/release/boost/thread/win32/tss.hpp | 2 +-
   branches/release/libs/thread/test/test_tss.cpp | 36 ++++++++++++++++++++++++++++++++++++
   3 files changed, 38 insertions(+), 2 deletions(-)

Modified: branches/release/boost/thread/pthread/tss.hpp
==============================================================================
--- branches/release/boost/thread/pthread/tss.hpp (original)
+++ branches/release/boost/thread/pthread/tss.hpp 2008-03-17 09:46:19 EDT (Mon, 17 Mar 2008)
@@ -86,7 +86,7 @@
         T* release()
         {
             T* const temp=get();
- detail::set_tss_data(this,0,0,false);
+ detail::set_tss_data(this,boost::shared_ptr<detail::tss_cleanup_function>(),0,false);
             return temp;
         }
         void reset(T* new_value=0)

Modified: branches/release/boost/thread/win32/tss.hpp
==============================================================================
--- branches/release/boost/thread/win32/tss.hpp (original)
+++ branches/release/boost/thread/win32/tss.hpp 2008-03-17 09:46:19 EDT (Mon, 17 Mar 2008)
@@ -85,7 +85,7 @@
         T* release()
         {
             T* const temp=get();
- detail::set_tss_data(this,0,0,false);
+ detail::set_tss_data(this,boost::shared_ptr<detail::tss_cleanup_function>(),0,false);
             return temp;
         }
         void reset(T* new_value=0)

Modified: branches/release/libs/thread/test/test_tss.cpp
==============================================================================
--- branches/release/libs/thread/test/test_tss.cpp (original)
+++ branches/release/libs/thread/test/test_tss.cpp 2008-03-17 09:46:19 EDT (Mon, 17 Mar 2008)
@@ -228,6 +228,41 @@
     timed_test(&do_test_tss_with_custom_cleanup, 2);
 }
 
+Dummy* tss_object=new Dummy;
+
+void tss_thread_with_custom_cleanup_and_release()
+{
+ tss_with_cleanup.reset(tss_object);
+ tss_with_cleanup.release();
+}
+
+void do_test_tss_does_no_cleanup_after_release()
+{
+ tss_cleanup_called=false;
+ boost::thread t(tss_thread_with_custom_cleanup_and_release);
+ try
+ {
+ t.join();
+ }
+ catch(...)
+ {
+ t.interrupt();
+ t.join();
+ throw;
+ }
+
+ BOOST_CHECK(!tss_cleanup_called);
+ if(!tss_cleanup_called)
+ {
+ delete tss_object;
+ }
+}
+
+void test_tss_does_no_cleanup_after_release()
+{
+ timed_test(&do_test_tss_does_no_cleanup_after_release, 2);
+}
+
 boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
 {
     boost::unit_test_framework::test_suite* test =
@@ -235,6 +270,7 @@
 
     test->add(BOOST_TEST_CASE(test_tss));
     test->add(BOOST_TEST_CASE(test_tss_with_custom_cleanup));
+ test->add(BOOST_TEST_CASE(test_tss_does_no_cleanup_after_release));
 
     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