diff options
author | mcorino <mcorino@users.noreply.github.com> | 2005-02-05 20:15:50 +0000 |
---|---|---|
committer | mcorino <mcorino@users.noreply.github.com> | 2005-02-05 20:15:50 +0000 |
commit | aabd0ab89b2a359593979eebf20737ef07c3ed39 (patch) | |
tree | fa82a07ba711a7a7aae208f8a8bb8c6ceb23d5bb | |
parent | bfb3b1e8b0c219af186981a679a2a4a24a9de5c5 (diff) | |
download | ATCD-aabd0ab89b2a359593979eebf20737ef07c3ed39.tar.gz |
ChangeLogTag: Sat Feb 4 20:12:37 2005 Martin Corino <mcorino@remedy.nl>
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ace/OS_NS_Thread.cpp | 24 | ||||
-rw-r--r-- | ace/OS_NS_Thread.h | 3 | ||||
-rw-r--r-- | ace/OS_NS_Thread.inl | 3 |
4 files changed, 32 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog index 539802bd798..99e18ffee07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Sat Feb 4 20:12:37 2005 Martin Corino <mcorino@remedy.nl> + + * ace/OS_NS_Thread.cpp: + * ace/OS_NS_Thread.h: + * ace/OS_NS_Thread.inl: + + Fixed some flaws in TSS_Emulation tests for TSS key validity introduced + some 3 years ago when key reuse was enabled for TSS_Emulation. + Sat Feb 4 15:17:37 2005 Martin Corino <mcorino@remedy.nl> * tests/run_test.pl: diff --git a/ace/OS_NS_Thread.cpp b/ace/OS_NS_Thread.cpp index ddb6d4aeef6..5f5cfd52fd0 100644 --- a/ace/OS_NS_Thread.cpp +++ b/ace/OS_NS_Thread.cpp @@ -403,6 +403,22 @@ ACE_TSS_Emulation::release_key (ACE_thread_key_t key) return 1; } +int +ACE_TSS_Emulation::is_key (ACE_thread_key_t key) +{ + ACE_OS_Recursive_Thread_Mutex_Guard ( + *static_cast <ACE_recursive_thread_mutex_t *> + (ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK])); + + if (tss_keys_used_ != 0 && + tss_keys_used_->is_set (key) == 1) + { + return 1; + } + return 0; +} + void * ACE_TSS_Emulation::tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX]) { @@ -620,7 +636,7 @@ ACE_TSS_Keys::test_and_clear (const ACE_thread_key_t key) u_int word, bit; find (key_index, word, bit); - if (ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit)) + if (word < ACE_WORDS && ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit)) { ACE_CLR_BITS (key_bit_words_[word], 1 << bit); return 0; @@ -638,7 +654,7 @@ ACE_TSS_Keys::is_set (const ACE_thread_key_t key) const u_int word, bit; find (key_index, word, bit); - return ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit); + return word < ACE_WORDS ? ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit) : 0; } /*****************************************************************************/ @@ -3515,9 +3531,7 @@ ACE_OS::thr_setspecific (ACE_thread_key_t key, void *data) // ACE_OS_TRACE ("ACE_OS::thr_setspecific"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_TSS_EMULATION) - ACE_KEY_INDEX (key_index, key); - - if (key_index >= ACE_TSS_Emulation::total_keys ()) + if (ACE_TSS_Emulation::is_key (key) == 0) { errno = EINVAL; data = 0; diff --git a/ace/OS_NS_Thread.h b/ace/OS_NS_Thread.h index 987f3c0f770..7775da2d2fa 100644 --- a/ace/OS_NS_Thread.h +++ b/ace/OS_NS_Thread.h @@ -863,6 +863,9 @@ public: /// new request. Returns 0 on success, 1 if the key was not reserved. static int release_key (ACE_thread_key_t key); + /// Check a key for validity. + static int is_key (ACE_thread_key_t key); + /// Returns the exit hook associated with the key. Does _not_ check /// for a valid key. static ACE_TSS_DESTRUCTOR tss_destructor (const ACE_thread_key_t key); diff --git a/ace/OS_NS_Thread.inl b/ace/OS_NS_Thread.inl index 2262fae16a2..14f783b47ea 100644 --- a/ace/OS_NS_Thread.inl +++ b/ace/OS_NS_Thread.inl @@ -3711,8 +3711,7 @@ ACE_OS::thr_getspecific (ACE_thread_key_t key, void **data) // ACE_OS_TRACE ("ACE_OS::thr_getspecific"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_TSS_EMULATION) - ACE_KEY_INDEX (key_index, key); - if (key_index >= ACE_TSS_Emulation::total_keys ()) + if (ACE_TSS_Emulation::is_key (key) == 0) { errno = EINVAL; data = 0; |