mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-11-16 12:34:45 +00:00
2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1855/cpukit * posix/src/psignal.c, posix/src/psignalunblockthread.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:
@@ -1,3 +1,13 @@
|
||||
2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>
|
||||
|
||||
PR 1855/cpukit
|
||||
* posix/src/psignal.c, posix/src/psignalunblockthread.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>
|
||||
|
||||
PR 1867/cpukit
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* COPYRIGHT (c) 1989-2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -106,6 +106,13 @@ void _POSIX_signals_Post_switch_extension(
|
||||
POSIX_API_Control *api;
|
||||
int signo;
|
||||
ISR_Level level;
|
||||
int hold_errno;
|
||||
|
||||
/*
|
||||
* 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 = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||
if ( !api )
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* COPYRIGHT (c) 1989-2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -103,21 +103,16 @@ bool _POSIX_signals_Unblock_thread(
|
||||
if ( the_thread->current_state & STATES_INTERRUPTIBLE_BY_SIGNAL ) {
|
||||
the_thread->Wait.return_code = EINTR;
|
||||
/*
|
||||
* At this time, there is no RTEMS API object which lets a task
|
||||
* block on a thread queue and be interruptible by a POSIX signal.
|
||||
* If an object class with that requirement is ever added, enable
|
||||
* this code.
|
||||
* In pthread_cond_wait, a thread will be blocking on a thread
|
||||
* queue, but is also interruptible by a POSIX signal.
|
||||
*/
|
||||
#if 0
|
||||
if ( _States_Is_waiting_on_thread_queue(the_thread->current_state) )
|
||||
_Thread_queue_Extract_with_proxy( the_thread );
|
||||
else
|
||||
#endif
|
||||
if ( _States_Is_delaying(the_thread->current_state) ){
|
||||
if ( _Watchdog_Is_active( &the_thread->Timer ) )
|
||||
else if ( _States_Is_delaying(the_thread->current_state) ){
|
||||
(void) _Watchdog_Remove( &the_thread->Timer );
|
||||
_Thread_Unblock( the_thread );
|
||||
}
|
||||
|
||||
} else if ( the_thread->current_state == STATES_READY ) {
|
||||
if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
|
||||
_ISR_Signals_to_thread_executing = TRUE;
|
||||
|
||||
@@ -185,7 +185,7 @@ bool _POSIX_Threads_Create_extension(
|
||||
_Thread_queue_Initialize(
|
||||
&api->Join_List,
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_JOIN_AT_EXIT,
|
||||
STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -66,6 +67,9 @@ int pthread_join(
|
||||
}
|
||||
_Thread_Enable_dispatch();
|
||||
|
||||
if ( _Thread_Executing->Wait.return_code == EINTR )
|
||||
goto on_EINTR;
|
||||
|
||||
if ( value_ptr )
|
||||
*value_ptr = return_pointer;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user