summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/keyrundestructors.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-25 10:54:49 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-31 08:29:43 +0200
commit1b1be254e7a3e3d6fe6d55d62010a81a7ef35411 (patch)
treec8bacf15b0f092728fd69debcb2387b65db33ed0 /cpukit/posix/src/keyrundestructors.c
parentscore: Replace _Thread_Reset() (diff)
downloadrtems-1b1be254e7a3e3d6fe6d55d62010a81a7ef35411.tar.bz2
score: Thread life cycle re-implementation
The thread deletion is now supported on SMP. This change fixes the following PRs: PR1814: SMP race condition between stack free and dispatch PR2035: psxcancel reveals NULL pointer access in _Thread_queue_Extract() The POSIX cleanup handler are now called in the right context (should be called in the context of the terminating thread). http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html Add a user extension the reflects a thread termination event. This is used to reclaim the Newlib reentrancy structure (may use file operations), the POSIX cleanup handlers and the POSIX key destructors.
Diffstat (limited to 'cpukit/posix/src/keyrundestructors.c')
-rw-r--r--cpukit/posix/src/keyrundestructors.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/cpukit/posix/src/keyrundestructors.c b/cpukit/posix/src/keyrundestructors.c
index 762e2e6f85..96147a539d 100644
--- a/cpukit/posix/src/keyrundestructors.c
+++ b/cpukit/posix/src/keyrundestructors.c
@@ -7,7 +7,7 @@
/*
* Copyright (c) 2012 Zhongwei Yao.
- * Copyright (c) 2010 embedded brains GmbH.
+ * Copyright (c) 2010-2014 embedded brains GmbH.
*
* COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
@@ -22,6 +22,7 @@
#endif
#include <rtems/posix/keyimpl.h>
+#include <rtems/score/assert.h>
#include <rtems/score/chainimpl.h>
#include <rtems/score/thread.h>
@@ -44,14 +45,15 @@ void _POSIX_Keys_Run_destructors(
POSIX_Keys_Control *the_key;
Objects_Locations location;
- _Thread_Disable_dispatch();
-
chain = &thread->Key_Chain;
iter = (POSIX_Keys_Key_value_pair *) _Chain_First( chain );
while ( !_Chain_Is_tail( chain, &iter->Key_values_per_thread_node ) ) {
next = (POSIX_Keys_Key_value_pair *)
_Chain_Next( &iter->Key_values_per_thread_node );
+ the_key = _POSIX_Keys_Get( iter->key, &location );
+ _Assert( location == OBJECTS_LOCAL );
+
/**
* remove key from rbtree and chain.
* here Chain_Node *iter can be convert to POSIX_Keys_Key_value_pair *,
@@ -64,21 +66,19 @@ void _POSIX_Keys_Run_destructors(
);
_Chain_Extract_unprotected( &iter->Key_values_per_thread_node );
- /**
- * run key value's destructor if destructor and value are both non-null.
- */
- the_key = _POSIX_Keys_Get( iter->key, &location );
destructor = the_key->destructor;
value = iter->value;
- if ( destructor != NULL && value != NULL )
- (*destructor)( value );
+
+ _POSIX_Keys_Key_value_pair_free( iter );
_Objects_Put( &the_key->Object );
- _POSIX_Keys_Key_value_pair_free( iter );
+ /**
+ * run key value's destructor if destructor and value are both non-null.
+ */
+ if ( destructor != NULL && value != NULL )
+ (*destructor)( value );
iter = next;
}
-
- _Thread_Enable_dispatch();
}