2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>

PR 1855/cpukit
	* posix/src/psignal.c, posix/src/pthread.c, posix/src/pthreadjoin.c:
	Correct signal processing during pthread_join. We are supposed to
	unblock the thread waiting on a pthread_join(), dispatch the signal
	handler, account for it potentially overwriting errno, and then have
	the thread return to blocking within pthread_join().
This commit is contained in:
Joel Sherrill
2011-07-31 22:40:23 +00:00
parent 76e9a52f29
commit f05af6b733
4 changed files with 24 additions and 2 deletions

View File

@@ -1,3 +1,12 @@
2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1855/cpukit
* posix/src/psignal.c, posix/src/pthread.c, posix/src/pthreadjoin.c:
Correct signal processing during pthread_join. We are supposed to
unblock the thread waiting on a pthread_join(), dispatch the signal
handler, account for it potentially overwriting errno, and then have
the thread return to blocking within pthread_join().
2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com> 2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1867/cpukit PR 1867/cpukit

View File

@@ -112,9 +112,16 @@ void _POSIX_signals_Post_switch_extension(
POSIX_API_Control *api; POSIX_API_Control *api;
int signo; int signo;
ISR_Level level; ISR_Level level;
int hold_errno;
api = the_thread->API_Extensions[ THREAD_API_POSIX ]; api = the_thread->API_Extensions[ THREAD_API_POSIX ];
/*
* We need to ensure that if the signal handler executes a call
* which overwrites the unblocking status, we restore it.
*/
hold_errno = _Thread_Executing->Wait.return_code;
/* /*
* api may be NULL in case of a thread close in progress * api may be NULL in case of a thread close in progress
*/ */
@@ -149,6 +156,8 @@ void _POSIX_signals_Post_switch_extension(
_POSIX_signals_Check_signal( api, signo, true ); _POSIX_signals_Check_signal( api, signo, true );
} }
} }
_Thread_Executing->Wait.return_code = hold_errno;
} }
/* /*

View File

@@ -217,7 +217,7 @@ bool _POSIX_Threads_Create_extension(
_Thread_queue_Initialize( _Thread_queue_Initialize(
&api->Join_List, &api->Join_List,
THREAD_QUEUE_DISCIPLINE_FIFO, THREAD_QUEUE_DISCIPLINE_FIFO,
STATES_WAITING_FOR_JOIN_AT_EXIT, STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
0 0
); );

View File

@@ -1,7 +1,7 @@
/* /*
* 16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147 * 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). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -32,6 +32,7 @@ int pthread_join(
Objects_Locations location; Objects_Locations location;
void *return_pointer; void *return_pointer;
on_EINTR:
the_thread = _Thread_Get( thread, &location ); the_thread = _Thread_Get( thread, &location );
switch ( location ) { switch ( location ) {
@@ -66,6 +67,9 @@ int pthread_join(
} }
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
if ( _Thread_Executing->Wait.return_code == EINTR )
goto on_EINTR;
if ( value_ptr ) if ( value_ptr )
*value_ptr = return_pointer; *value_ptr = return_pointer;
return 0; return 0;