diff options
author | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2008-01-18 16:31:57 +0000 |
---|---|---|
committer | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2008-01-18 16:31:57 +0000 |
commit | c3925dbe923bf0944235bc2c4556955f35b0dc91 (patch) | |
tree | cebd73d709e9f2c152f42d14362923dded35f0ef /cpukit/posix/src/cleanuppop.c | |
parent | 2008-01-18 David Erickson <David.Erickson@drdc-rddc.gc.ca> (diff) | |
download | rtems-c3925dbe923bf0944235bc2c4556955f35b0dc91.tar.bz2 |
2008-01-18 Jennifer Averett <jennifer.averett@OARcorp.com>
* posix/include/rtems/posix/timer.h, posix/src/cleanuppop.c,
posix/src/cleanuppush.c, posix/src/mqueueclose.c,
posix/src/timergettime.c, posix/src/timersettime.c,
score/include/rtems/score/timespec.h:
Diffstat (limited to 'cpukit/posix/src/cleanuppop.c')
-rw-r--r-- | cpukit/posix/src/cleanuppop.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/cpukit/posix/src/cleanuppop.c b/cpukit/posix/src/cleanuppop.c index f919228801..cc327fa33d 100644 --- a/cpukit/posix/src/cleanuppop.c +++ b/cpukit/posix/src/cleanuppop.c @@ -1,5 +1,5 @@ /* - * COPYRIGHT (c) 1989-2007. + * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -44,8 +44,18 @@ void pthread_cleanup_pop( handler_stack = &thread_support->Cancellation_Handlers; + /* + * We need interrupts disabled to safely check the chain and pull + * the last element off. But we also need dispatching disabled to + * ensure that we do not get prempted and deleted while we are holding + * memory that needs to be freed. + */ + + _Thread_Disable_dispatch(); _ISR_Disable( level ); + if ( _Chain_Is_empty( handler_stack ) ) { + _Thread_Enable_dispatch(); _ISR_Enable( level ); return; } @@ -58,8 +68,8 @@ void pthread_cleanup_pop( tmp_handler = *handler; - _Thread_Disable_dispatch(); - _Workspace_Free( handler ); + _Workspace_Free( handler ); + _Thread_Enable_dispatch(); if ( execute ) |