From f845e96e7beef7d6db35c80e0075dcb07a71dce3 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 5 Jul 2002 18:13:18 +0000 Subject: 2002-07-05 Joel Sherrill * include/rtems/posix/cancel.h, src/cancel.c, src/cancelrun.c, src/mqueue.c, src/pthread.c, src/semaphore.c, src/setcancelstate.c, src/setcanceltype.c, src/testcancel.c: Per PR164, corrected the behavior of thread cancellation and did some cleanup as a side-effect. --- cpukit/posix/src/cancel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cpukit/posix/src/cancel.c') diff --git a/cpukit/posix/src/cancel.c b/cpukit/posix/src/cancel.c index 88012040fb..f1310d5ab1 100644 --- a/cpukit/posix/src/cancel.c +++ b/cpukit/posix/src/cancel.c @@ -31,6 +31,13 @@ int pthread_cancel( POSIX_API_Control *thread_support; Objects_Locations location; + /* + * Don't even think about deleting a resource from an ISR. + */ + + if ( _ISR_Is_in_progress() ) + return EPROTO; + the_thread = _POSIX_Threads_Get( thread, &location ); switch ( location ) { case OBJECTS_ERROR: @@ -42,6 +49,11 @@ int pthread_cancel( thread_support->cancelation_requested = 1; + if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE && + thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS ) { + _POSIX_Threads_cancel_run( the_thread ); + } + _Thread_Enable_dispatch(); return 0; } -- cgit v1.2.3