Implemented and tested cc_ccache_wait_for_change()
authorAlexandra Ellwood <lxs@mit.edu>
Tue, 31 Jul 2007 20:23:02 +0000 (20:23 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Tue, 31 Jul 2007 20:23:02 +0000 (20:23 +0000)
ticket: 4644
status: open

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19740 dc483132-0cff-0310-8789-dd5450dbe970

src/ccapi/lib/ccapi_context.c
src/ccapi/server/ccs_cache_collection.c
src/ccapi/server/ccs_callback.c
src/ccapi/server/ccs_ccache.c
src/ccapi/server/ccs_client.c

index feccc85a411f0672a577b69e1a2f80116189fcea..1aef3a696b19e7c06a364d682002fef0535a6efd 100644 (file)
@@ -125,6 +125,7 @@ cc_int32 cc_initialize (cc_context_t  *out_context,
             case ccapi_version_4:
             case ccapi_version_5:
             case ccapi_version_6:
+            case ccapi_version_7:
                 break;
             
             default: 
index 543f99c2079fdaa790216a8203b7ae0b1195dc66..f838c9ade675a2056f09f29784c90907c8537fc0 100644 (file)
@@ -484,6 +484,7 @@ cc_int32 ccs_cache_collection_set_default_ccache (ccs_cache_collection_t  io_cac
     cc_int32 err = ccNoError;
     ccs_ccache_t old_default = NULL;
     ccs_ccache_t new_default = NULL;
+    cc_uint32 equal = 0;
     
     if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
     if (!in_identifier      ) { err = cci_check_error (ccErrBadParam); }
@@ -494,29 +495,34 @@ cc_int32 ccs_cache_collection_set_default_ccache (ccs_cache_collection_t  io_cac
     }
     
     if (!err) {
-        err = ccs_ccache_list_push_front (io_cache_collection->ccaches,
-                                          in_identifier);
-    }
-    
-    if (!err) {
-        err = ccs_ccache_notify_default_state_changed (old_default,
-                                                       io_cache_collection,
-                                                       FALSE /* no longer default */);
-    }
-    
-    if (!err) {
-        err = ccs_cache_collection_get_default_ccache (io_cache_collection, 
-                                                       &new_default);
+       err = ccs_ccache_compare_identifier (old_default, in_identifier, &equal);
     }
     
-    if (!err) {
-        err = ccs_ccache_notify_default_state_changed (new_default,
-                                                       io_cache_collection,
-                                                       TRUE /* now default */);
-    }
     
-    if (!err) {
-        err = ccs_cache_collection_changed (io_cache_collection);
+    if (!err && !equal) {
+        err = ccs_ccache_list_push_front (io_cache_collection->ccaches,
+                                          in_identifier);
+       
+       if (!err) {
+           err = ccs_ccache_notify_default_state_changed (old_default,
+                                                          io_cache_collection,
+                                                          FALSE /* no longer default */);
+       }
+       
+       if (!err) {
+           err = ccs_cache_collection_get_default_ccache (io_cache_collection, 
+                                                          &new_default);
+       }
+       
+       if (!err) {
+           err = ccs_ccache_notify_default_state_changed (new_default,
+                                                          io_cache_collection,
+                                                          TRUE /* now default */);
+       }
+       
+       if (!err) {
+           err = ccs_cache_collection_changed (io_cache_collection);
+       }
     }
 
     return cci_check_error (err);
index 1076d9025c69f5c386fe8e73ce1b7c4fbff229c0..3088258abbcd703d3cfce36509152ab5edf9c9eb 100644 (file)
@@ -117,7 +117,8 @@ cc_int32 ccs_callback_release (ccs_callback_t io_callback)
            err = ccs_server_client_for_pipe (io_callback->client_pipe, &client);
        }
        
-       if (!err) {
+       if (!err && client) {
+           /* if client object still has a reference to us, remove it */
            err = ccs_client_remove_callback (client, io_callback);
        }
        
index 3eab42fa7a4286a8939336335f97d1a2c9423a20..93c0c46d11a3ab8bad5320fceafb09ee3bacf179 100644 (file)
@@ -118,6 +118,8 @@ cc_int32 ccs_ccache_new (ccs_ccache_t      *out_ccache,
         if (!err) {
             /* first cache is default */
             ccache->last_default_time = (count == 0) ? now : 0;
+           cci_debug_printf ("%s ccache->last_default_time is %d.", 
+                            __FUNCTION__, ccache->last_default_time);
             ccache->last_changed_time = now;
         }
     }
@@ -862,6 +864,7 @@ static cc_int32 ccs_ccache_wait_for_change (ccs_pipe_t              in_client_pi
     
     if (!err) {
        if (last_wait_for_change_time < io_ccache->last_changed_time) {
+           cci_debug_printf ("%s returning immediately", __FUNCTION__);
            err = cci_stream_write_time (io_reply_data, io_ccache->last_changed_time);
            
        } else {
@@ -879,6 +882,7 @@ static cc_int32 ccs_ccache_wait_for_change (ccs_pipe_t              in_client_pi
                                                 ccs_callback_array_count (io_ccache->change_callbacks));
                if (!err) { callback = NULL; /* take ownership */ }
                
+               cci_debug_printf ("%s blocking", __FUNCTION__);
                will_block = 1;
            }
            
index 9e8a81c8bdc6274bce115545a6aa55fa06244b6d..b29616f345cd99a6ffd26a6217a5306e946bbbe6 100644 (file)
@@ -121,7 +121,7 @@ cc_int32 ccs_client_remove_callback (ccs_client_t   io_client,
                                     ccs_callback_t in_callback)
 {
     cc_int32 err = ccNoError;
-    cc_uint32 found_lock = 0;
+    cc_uint32 found_callback = 0;
     
     if (!io_client) { err = cci_check_error (ccErrBadParam); }
     
@@ -134,13 +134,14 @@ cc_int32 ccs_client_remove_callback (ccs_client_t   io_client,
             
             if (callback == in_callback) {
                cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback);
+               found_callback = 1;
                err = ccs_callbackref_array_remove (io_client->callbacks, i);
                break;
             }
         }
     }
     
-    if (!err && !found_lock) {
+    if (!err && !found_callback) {
         cci_debug_printf ("%s: WARNING! callback not found.", __FUNCTION__);
     }