summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-10-13 21:37:54 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-10-13 21:37:54 +0000
commit17f1ffbe0f75563ac96cbe541cc5afb38c5d9b6a (patch)
tree715c909c792cc39f1f841991c6a6aff339550681 /cpukit/posix
parent67113c7655f2bb48f1a3b856f24195eb3077ded4 (diff)
downloadrtems-17f1ffbe0f75563ac96cbe541cc5afb38c5d9b6a.tar.bz2
2003-10-13 Joel Sherrill <joel@OARcorp.com>
* src/cleanuppop.c, src/cleanuppush.c: Protect use of _Workspace_Allocate and _Workspec_Free.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/ChangeLog5
-rw-r--r--cpukit/posix/src/cleanuppop.c20
-rw-r--r--cpukit/posix/src/cleanuppush.c7
3 files changed, 25 insertions, 7 deletions
diff --git a/cpukit/posix/ChangeLog b/cpukit/posix/ChangeLog
index 5112c22d15..4aa6e520ac 100644
--- a/cpukit/posix/ChangeLog
+++ b/cpukit/posix/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-13 Joel Sherrill <joel@OARcorp.com>
+
+ * src/cleanuppop.c, src/cleanuppush.c: Protect use of
+ _Workspace_Allocate and _Workspec_Free.
+
2003-09-04 Joel Sherrill <joel@OARcorp.com>
* include/rtems/posix/cond.h, include/rtems/posix/condmp.h,
diff --git a/cpukit/posix/src/cleanuppop.c b/cpukit/posix/src/cleanuppop.c
index f477d1f0c8..d7a4c0ca11 100644
--- a/cpukit/posix/src/cleanuppop.c
+++ b/cpukit/posix/src/cleanuppop.c
@@ -28,6 +28,7 @@ void pthread_cleanup_pop(
)
{
POSIX_Cancel_Handler_control *handler;
+ POSIX_Cancel_Handler_control tmp_handler;
Chain_Control *handler_stack;
POSIX_API_Control *thread_support;
ISR_Level level;
@@ -36,17 +37,24 @@ void pthread_cleanup_pop(
handler_stack = &thread_support->Cancellation_Handlers;
- if ( _Chain_Is_empty( handler_stack ) )
- return;
-
_ISR_Disable( level );
+ if ( _Chain_Is_empty( handler_stack ) ) {
+ _ISR_Enable( level );
+ return;
+ }
+
handler = (POSIX_Cancel_Handler_control *)
_Chain_Tail( handler_stack )->previous;
_Chain_Extract_unprotected( &handler->Node );
+
_ISR_Enable( level );
+ tmp_handler = *handler;
+
+ _Thread_Disable_dispatch();
+ _Workspace_Free( handler );
+ _Thread_Enable_dispatch();
+
if ( execute )
- (*handler->routine)( handler->arg );
-
- _Workspace_Free( handler );
+ (*tmp_handler.routine)( tmp_handler.arg );
}
diff --git a/cpukit/posix/src/cleanuppush.c b/cpukit/posix/src/cleanuppush.c
index bf96212d8f..80193749e6 100644
--- a/cpukit/posix/src/cleanuppush.c
+++ b/cpukit/posix/src/cleanuppush.c
@@ -35,10 +35,13 @@ void pthread_cleanup_push(
if ( !routine )
return; /* XXX what to do really? */
+ _Thread_Disable_dispatch();
handler = _Workspace_Allocate( sizeof( POSIX_Cancel_Handler_control ) );
- if ( !handler )
+ if ( !handler ) {
+ _Thread_Enable_dispatch();
return; /* XXX what to do really? */
+ }
thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
@@ -48,4 +51,6 @@ void pthread_cleanup_push(
handler->arg = arg;
_Chain_Append( handler_stack, &handler->Node );
+
+ _Thread_Enable_dispatch();
}