summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadjoin.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-31 16:16:00 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-31 16:16:00 +0000
commit25715ecc42ba6775128324ccdc67446e5bc6d09b (patch)
tree425693870fb6f7f8b6afa90fee6f1060fd580a0c /cpukit/posix/src/pthreadjoin.c
parent2011-07-29 Pawel Zagorski <pzagor@agh.edu.pl> (diff)
downloadrtems-25715ecc42ba6775128324ccdc67446e5bc6d09b.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 'cpukit/posix/src/pthreadjoin.c')
-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 )