object_mgr_remove_from_map() is doing the exact same thing
as object_mgr_invalidate_handle().

This patch removes object_mgr_remove_from_map() and changes
all of it's callers to call object_mgr_invalidate_handle1()
instead

Signed-off-by: Klaus Heinrich Kiwi <[email protected]>
---
 usr/lib/pkcs11/common/h_extern.h  |    2 -
 usr/lib/pkcs11/common/mech_ssl3.c |   12 ++++----
 usr/lib/pkcs11/common/obj_mgr.c   |   49 ++++++-------------------------------
 3 files changed, 14 insertions(+), 49 deletions(-)

diff --git a/usr/lib/pkcs11/common/h_extern.h b/usr/lib/pkcs11/common/h_extern.h
index ade139c..9cf34c1 100755
--- a/usr/lib/pkcs11/common/h_extern.h
+++ b/usr/lib/pkcs11/common/h_extern.h
@@ -1934,8 +1934,6 @@ CK_BBOOL object_mgr_purge_token_objects( void );
 
 CK_BBOOL object_mgr_purge_private_token_objects( void );
 
-CK_RV    object_mgr_remove_from_map( CK_OBJECT_HANDLE handle );
-
 CK_RV    object_mgr_restore_obj( CK_BYTE *data, OBJECT *oldObj );
 
 CK_RV    object_mgr_set_attribute_values( SESSION          * sess,
diff --git a/usr/lib/pkcs11/common/mech_ssl3.c 
b/usr/lib/pkcs11/common/mech_ssl3.c
index 85cdf2a..5f53851 100755
--- a/usr/lib/pkcs11/common/mech_ssl3.c
+++ b/usr/lib/pkcs11/common/mech_ssl3.c
@@ -1775,10 +1775,10 @@ ssl3_key_and_mac_derive( SESSION           * sess,
 error:
 
    if (client_write_handle != 0)
-      object_mgr_remove_from_map( client_write_handle );
+      object_mgr_invalidate_handle1( client_write_handle );
 
    if (server_write_handle != 0)
-      object_mgr_remove_from_map( server_write_handle );
+      object_mgr_invalidate_handle1( server_write_handle );
 
    return rc;
 }
@@ -1941,8 +1941,8 @@ ssl3_kmd_process_mac_keys( SESSION           * sess,
    return CKR_OK;
 
 error:
-   if (*client_handle != 0) object_mgr_remove_from_map( *client_handle );
-   if (*server_handle != 0) object_mgr_remove_from_map( *server_handle );
+   if (*client_handle != 0) object_mgr_invalidate_handle1( *client_handle );
+   if (*server_handle != 0) object_mgr_invalidate_handle1( *server_handle );
 
    if (client_obj) {
       object_free( client_obj );
@@ -2198,10 +2198,10 @@ ssl3_kmd_process_write_keys( SESSION           * sess,
 
 error:
    if (*client_handle != 0)
-      object_mgr_remove_from_map( *client_handle );
+      object_mgr_invalidate_handle1( *client_handle );
 
    if (*server_handle != 0)
-      object_mgr_remove_from_map( *server_handle );
+      object_mgr_invalidate_handle1( *server_handle );
 
    if (client_obj)
       object_free( client_obj );
diff --git a/usr/lib/pkcs11/common/obj_mgr.c b/usr/lib/pkcs11/common/obj_mgr.c
index 9596fd9..64eda19 100755
--- a/usr/lib/pkcs11/common/obj_mgr.c
+++ b/usr/lib/pkcs11/common/obj_mgr.c
@@ -1033,7 +1033,7 @@ object_mgr_destroy_object( SESSION          * sess,
 
       node = dlist_find( sess_obj_list, obj );
       if (node) {
-         object_mgr_remove_from_map( handle );
+         object_mgr_invalidate_handle1( handle );
 
          object_free( obj );
          sess_obj_list = dlist_remove_node( sess_obj_list, node );
@@ -1062,7 +1062,7 @@ object_mgr_destroy_object( SESSION          * sess,
 
          XProcUnLock( xproclock );
 
-         object_mgr_remove_from_map( handle );
+         object_mgr_invalidate_handle1( handle );
 
          object_free( obj );
 
@@ -1113,7 +1113,7 @@ object_mgr_destroy_token_objects( void )
       if (rc == CKR_OK) {
          // only if it's found in the object map.  it might not be there
          //
-         object_mgr_remove_from_map( handle );
+         object_mgr_invalidate_handle1( handle );
       }
       else{
          st_err_log(110, __FILE__, __LINE__);
@@ -1133,7 +1133,7 @@ object_mgr_destroy_token_objects( void )
       if (rc == CKR_OK) {
          // only if it's found in the object map.  it might not be there
          //
-         object_mgr_remove_from_map( handle );
+         object_mgr_invalidate_handle1( handle );
       }
       else{
          st_err_log(110, __FILE__, __LINE__);
@@ -1892,39 +1892,6 @@ object_mgr_purge_private_token_objects( void )
 }
 
 
-// object_mgr_remove_from_map()
-//
-CK_RV
-object_mgr_remove_from_map( CK_OBJECT_HANDLE  handle )
-{
-   DL_NODE  *node = NULL;
-
-   //
-   // no mutex stuff here.  the calling routine should have locked the mutex
-   //
-
-   if (pthread_rwlock_wrlock(&obj_list_rw_mutex)) {
-     st_err_log(4, __FILE__, __LINE__, __FUNCTION__);
-     return CKR_FUNCTION_FAILED;
-   }
-   node = object_map;
-   while (node) {
-      OBJECT_MAP *map = (OBJECT_MAP *)node->data;
-      if (map->handle == handle) {
-         object_map = dlist_remove_node( object_map, node );
-         free( map );
-        pthread_rwlock_unlock(&obj_list_rw_mutex);
-         return CKR_OK;
-      }
-      node = node->next;
-   }
-   pthread_rwlock_unlock(&obj_list_rw_mutex);
-
-   st_err_log(4, __FILE__, __LINE__, __FUNCTION__); 
-   return CKR_FUNCTION_FAILED;
-}
-
-
 //
 //
 CK_RV
@@ -2474,7 +2441,7 @@ object_mgr_update_publ_tok_obj_from_shm()
          rc = object_mgr_find_in_map2( obj, &handle );
          if (rc == CKR_OK){
             st_err_log(110, __FILE__, __LINE__);
-            object_mgr_remove_from_map( handle );
+            object_mgr_invalidate_handle1( handle );
          }
          object_free( obj );
 
@@ -2557,7 +2524,7 @@ object_mgr_update_publ_tok_obj_from_shm()
          rc = object_mgr_find_in_map2( obj, &handle );
          if (rc == CKR_OK){
             st_err_log(110, __FILE__, __LINE__);
-            object_mgr_remove_from_map( handle );
+            object_mgr_invalidate_handle1( handle );
          }
          object_free( obj );
 
@@ -2615,7 +2582,7 @@ object_mgr_update_priv_tok_obj_from_shm()
          rc = object_mgr_find_in_map2( obj, &handle );
          if (rc == CKR_OK){
             st_err_log(110, __FILE__, __LINE__);
-            object_mgr_remove_from_map( handle );
+            object_mgr_invalidate_handle1( handle );
          }
          object_free( obj );
 
@@ -2698,7 +2665,7 @@ object_mgr_update_priv_tok_obj_from_shm()
          rc = object_mgr_find_in_map2( obj, &handle );
          if (rc == CKR_OK){
             st_err_log(110, __FILE__, __LINE__);
-            object_mgr_remove_from_map( handle );
+            object_mgr_invalidate_handle1( handle );
          }
          object_free( obj );
 
-- 
1.6.6.1


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Opencryptoki-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech

Reply via email to