Boost logo

Boost-Commit :

From: anthony_at_[hidden]
Date: 2008-03-17 04:36:10


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

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

Modified: trunk/boost/thread/pthread/tss.hpp
==============================================================================
--- trunk/boost/thread/pthread/tss.hpp (original)
+++ trunk/boost/thread/pthread/tss.hpp 2008-03-17 04:36:09 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: trunk/boost/thread/win32/tss.hpp
==============================================================================
--- trunk/boost/thread/win32/tss.hpp (original)
+++ trunk/boost/thread/win32/tss.hpp 2008-03-17 04:36:09 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: trunk/libs/thread/test/test_tss.cpp
==============================================================================
--- trunk/libs/thread/test/test_tss.cpp (original)
+++ trunk/libs/thread/test/test_tss.cpp 2008-03-17 04:36:09 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