diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | ace/TSS_T.cpp | 21 |
2 files changed, 28 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog index 01a7b01bc63..71053959481 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Tue Nov 11 18:02:56 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * ace/TSS_T.cpp (ts_object): + + Added the change "Mon Nov 10 22:30:14 2003 Kobi Cohen-Arazi + <kobi@mivzak.com>" back into the repo. The actual problem lay + elsewhere. Please see below. + + + The double checked locking optimization in ts_init () was the + culprit. After grabbing the lock, if the check for null pointer + fails, meaning it was aloready allocated, just return 0 instead + of a -1. + Tue Nov 11 17:25:10 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> * ace/TSS_T.cpp: diff --git a/ace/TSS_T.cpp b/ace/TSS_T.cpp index c2cb22847c0..ac474228bda 100644 --- a/ace/TSS_T.cpp +++ b/ace/TSS_T.cpp @@ -73,7 +73,7 @@ ACE_TSS<TYPE>::dump (void) const #endif /* ACE_HAS_DUMP */ } -#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) +#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) #if defined (ACE_HAS_THR_C_DEST) extern "C" void ACE_TSS_C_cleanup(void *); // defined in Synch.cpp #endif /* ACE_HAS_THR_C_DEST */ @@ -112,7 +112,7 @@ ACE_TSS<TYPE>::ts_init (void) const } } - return -1; + return 0; } template <class TYPE> @@ -176,8 +176,12 @@ template <class TYPE> TYPE * ACE_TSS<TYPE>::ts_get (void) const { if (this->once_ == 0) - // Create and initialize thread-specific ts_obj. - this->ts_init (); + { + // Create and initialize thread-specific ts_obj. + if (this->ts_init () == -1) + // Seriously wrong.. + return 0; + } TYPE *ts_obj = 0; @@ -286,8 +290,11 @@ ACE_TSS<TYPE>::ts_object (TYPE *new_ts_obj) // <ts_init> does it for us and we'll end up with deadlock // otherwise... if (this->once_ == 0) - // Create and initialize thread-specific ts_obj. - this->ts_init (); + { + // Create and initialize thread-specific ts_obj. + if (this->ts_init () == -1) + return 0; + } // Ensure that we are serialized! ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->keylock_, 0); @@ -682,6 +689,6 @@ ACE_TSS_Read_Guard<ACE_LOCK>::dump (void) const #endif /* ACE_HAS_DUMP */ } -#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */ +#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */ #endif /* ACE_TSS_T_C */ |