summaryrefslogtreecommitdiff
path: root/cpukit/posix/src/pthreadjoin.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix/src/pthreadjoin.c')
-rw-r--r--cpukit/posix/src/pthreadjoin.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c
index 8ee9888b94..38f2389ea4 100644
--- a/cpukit/posix/src/pthreadjoin.c
+++ b/cpukit/posix/src/pthreadjoin.c
@@ -1,7 +1,7 @@
/*
* 16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -32,6 +32,7 @@ int pthread_join(
Objects_Locations location;
void *return_pointer;
+on_EINTR:
the_thread = _Thread_Get( thread, &location );
switch ( location ) {
@@ -52,13 +53,23 @@ 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)
+ );
+ _Thread_Enable_dispatch();
+ } 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();
- _Thread_Enable_dispatch();
+ if ( _Thread_Executing->Wait.return_code == EINTR )
+ goto on_EINTR;
+ }
if ( value_ptr )
*value_ptr = return_pointer;