diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-09-03 01:01:15 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-09-03 01:01:15 +0000 |
commit | ce06efb3735abc900371e5b99aeca842ced62c48 (patch) | |
tree | 41fc5d712078f286429363a51182ff8d05620595 /tests/Thread_Manager_Test.cpp | |
parent | 027284c46aa3e7c0aea244932f77897024b58eae (diff) | |
download | ATCD-ce06efb3735abc900371e5b99aeca842ced62c48.tar.gz |
dynamically allocate the signal_catcher so that we can destroy it before the main thread's TSS is cleaned up
Diffstat (limited to 'tests/Thread_Manager_Test.cpp')
-rw-r--r-- | tests/Thread_Manager_Test.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/Thread_Manager_Test.cpp b/tests/Thread_Manager_Test.cpp index f63e963ac2b..7b9940d70e5 100644 --- a/tests/Thread_Manager_Test.cpp +++ b/tests/Thread_Manager_Test.cpp @@ -49,14 +49,15 @@ private: // Each thread keeps track of whether it has been signaled within a // separate TSS entry. -static ACE_TSS<Signal_Catcher> signal_catcher; +// See comment below about why it's dynamically allocated. +static ACE_TSS<Signal_Catcher> *signal_catcher; extern "C" void handler (int signum) { ACE_DEBUG ((LM_DEBUG, "(%t) received signal %d, signaled = %d\n", - signum, signal_catcher->signaled ())); - signal_catcher->signaled (1); + signum, (*signal_catcher)->signaled ())); + (*signal_catcher)->signaled (1); } static void * @@ -71,7 +72,7 @@ worker (int iterations) if ((i % 1000) == 0) { #if !defined (ACE_LACKS_UNIX_SIGNALS) - if (signal_catcher->signaled () > 0 + if ((*signal_catcher)->signaled () > 0 // Only test for cancellation after we've been signaled, to // avoid race conditions for suspend() and resume(). && thr_mgr->testcancel (ACE_Thread::self ()) != 0) @@ -102,6 +103,11 @@ main (int, char *[]) ACE_START_TEST ("Thread_Manager_Test"); #if defined (ACE_HAS_THREADS) + // Dynamically allocate signal_catcher so that we can control when + // it gets deleted. Specifically, we need to delete it before + // the main thread's TSS is cleaned up. + ACE_NEW_RETURN (signal_catcher, ACE_TSS<Signal_Catcher>, 1); + ACE_Service_Config daemon; // Register a signal handler. @@ -149,6 +155,9 @@ main (int, char *[]) #else ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); #endif /* ACE_HAS_THREADS */ + + delete signal_catcher; + ACE_END_TEST; return 0; } |