[rtems commit] posix: Use _Objects_Put() for POSIX keys

Sebastian Huber sebh at rtems.org
Tue Aug 6 13:44:13 UTC 2013


Module:    rtems
Branch:    master
Commit:    b45b0ff7832361bbbccb5bb0006c9755139a9d30
Changeset: http://git.rtems.org/rtems/commit/?id=b45b0ff7832361bbbccb5bb0006c9755139a9d30

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Aug  6 15:41:44 2013 +0200

posix: Use _Objects_Put() for POSIX keys

---

 cpukit/posix/src/keygetspecific.c    |    7 +++++--
 cpukit/posix/src/keyrundestructors.c |    6 ++----
 cpukit/posix/src/keysetspecific.c    |   12 ++++++++----
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/cpukit/posix/src/keygetspecific.c b/cpukit/posix/src/keygetspecific.c
index 568a98c..011917b 100644
--- a/cpukit/posix/src/keygetspecific.c
+++ b/cpukit/posix/src/keygetspecific.c
@@ -38,13 +38,14 @@ void *pthread_getspecific(
   pthread_key_t  key
 )
 {
+  POSIX_Keys_Control          *the_key;
   Objects_Locations            location;
   POSIX_Keys_Key_value_pair    search_node;
   RBTree_Node                 *p;
   void                        *key_data;
   POSIX_Keys_Key_value_pair   *value_pair_p;
 
-  _POSIX_Keys_Get( key, &location );
+  the_key = _POSIX_Keys_Get( key, &location );
   switch ( location ) {
 
     case OBJECTS_LOCAL:
@@ -62,7 +63,9 @@ void *pthread_getspecific(
         /*                                  Key_value_lookup_node )->value; */
         key_data = value_pair_p->value;
       }
-      _Thread_Enable_dispatch();
+
+      _Objects_Put( &the_key->Object );
+
       return key_data;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/keyrundestructors.c b/cpukit/posix/src/keyrundestructors.c
index d151f4f..078f8f6 100644
--- a/cpukit/posix/src/keyrundestructors.c
+++ b/cpukit/posix/src/keyrundestructors.c
@@ -75,10 +75,8 @@ void _POSIX_Keys_Run_destructors(
     value = ((POSIX_Keys_Key_value_pair *)iter)->value;
     if ( destructor != NULL && value != NULL )
       (*destructor)( value );
-    /**
-     * disable dispatch is nested here
-     */
-    _Thread_Enable_dispatch();
+
+    _Objects_Put( &the_key->Object );
 
     /**
      * put back this node to keypool
diff --git a/cpukit/posix/src/keysetspecific.c b/cpukit/posix/src/keysetspecific.c
index 4a1adb6..ee718a4 100644
--- a/cpukit/posix/src/keysetspecific.c
+++ b/cpukit/posix/src/keysetspecific.c
@@ -34,18 +34,20 @@ int pthread_setspecific(
   const void    *value
 )
 {
+  POSIX_Keys_Control          *the_key;
   Objects_Locations            location;
   POSIX_Keys_Key_value_pair   *value_pair_ptr;
   POSIX_API_Control           *api;
 
-  _POSIX_Keys_Get( key, &location );
+  the_key = _POSIX_Keys_Get( key, &location );
   switch ( location ) {
 
     case OBJECTS_LOCAL:
       value_pair_ptr = ( POSIX_Keys_Key_value_pair * )
         _Freechain_Get( &_POSIX_Keys_Keypool.super_fc );
       if ( !value_pair_ptr ) {
-        _Thread_Enable_dispatch();
+        _Objects_Put( &the_key->Object );
+
         return ENOMEM;
       }
 
@@ -56,7 +58,8 @@ int pthread_setspecific(
                                        &(value_pair_ptr->Key_value_lookup_node) ) ) {
         _Freechain_Put( (Freechain_Control *)&_POSIX_Keys_Keypool,
                         (void *) value_pair_ptr );
-        _Thread_Enable_dispatch();
+        _Objects_Put( &the_key->Object );
+
         return EAGAIN;
       }
 
@@ -65,7 +68,8 @@ int pthread_setspecific(
        (_Thread_Executing->API_Extensions[THREAD_API_POSIX]);
       _Chain_Append_unprotected( &api->Key_Chain, &value_pair_ptr->Key_values_per_thread_node );
 
-      _Thread_Enable_dispatch();
+      _Objects_Put( &the_key->Object );
+
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)




More information about the vc mailing list