case ccapi_version_4:
case ccapi_version_5:
case ccapi_version_6:
+ case ccapi_version_7:
break;
default:
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); }
}
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);
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);
}
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;
}
}
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 {
ccs_callback_array_count (io_ccache->change_callbacks));
if (!err) { callback = NULL; /* take ownership */ }
+ cci_debug_printf ("%s blocking", __FUNCTION__);
will_block = 1;
}
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); }
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__);
}