summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadjoin.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-31 16:16:30 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-31 16:16:30 +0000
commit13893343187f4cbbcc132db3c1663dab5f6729d1 (patch)
treec149ddf58d34006415f45ab53345e273b4b0d4b3 /cpukit/posix/src/pthreadjoin.c
parent2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff)
downloadrtems-13893343187f4cbbcc132db3c1663dab5f6729d1.tar.bz2
2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1867/cpukit * posix/src/pthreadexit.c, posix/src/pthreadjoin.c: Correct implementation of pthread_exit() and pthread_join() to support the case where a thread is joinable but calls pthread_exit() before a thread has attempted to join.
Diffstat (limited to '')
-rw-r--r--cpukit/posix/src/pthreadjoin.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c
index 8ee9888b94..26d53285dc 100644
--- a/cpukit/posix/src/pthreadjoin.c
+++ b/cpukit/posix/src/pthreadjoin.c
@@ -52,12 +52,18 @@ int pthread_join(
* Put ourself on the threads join list
*/
- _Thread_Executing->Wait.return_argument = &return_pointer;
-
- _Thread_queue_Enter_critical_section( &api->Join_List );
-
- _Thread_queue_Enqueue( &api->Join_List, WATCHDOG_NO_TIMEOUT );
-
+ if ( the_thread->current_state ==
+ (STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_TRANSIENT) ) {
+ return_pointer = the_thread->Wait.return_argument;
+ _Thread_Clear_state(
+ the_thread,
+ (STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_TRANSIENT)
+ );
+ } else {
+ _Thread_Executing->Wait.return_argument = &return_pointer;
+ _Thread_queue_Enter_critical_section( &api->Join_List );
+ _Thread_queue_Enqueue( &api->Join_List, WATCHDOG_NO_TIMEOUT );
+ }
_Thread_Enable_dispatch();
if ( value_ptr )