{
cc_int32 err = ccNoError;
- if (!io_array) { err = ccErrBadParam; }
-
- if (!err) {
+ if (!err && io_array) {
cc_uint64 i;
if (io_array->object_release) {
{
cc_int32 err = ccNoError;
- if (!in_identifier) { err = ccErrBadParam; }
-
/* Do not free the static "uninitialized" identifier */
- if (!err && in_identifier != cci_identifier_uninitialized) {
+ if (!err && in_identifier && in_identifier != cci_identifier_uninitialized) {
free (in_identifier->server_id);
free (in_identifier->object_id);
free (in_identifier);
}
- return err;
+ return cci_check_error (err);
}
#pragma mark -
{
cc_int32 err = ccNoError;
- if (!io_stream) { err = ccErrBadParam; }
-
- if (!err) {
+ if (!err && io_stream) {
free (io_stream->data);
free (io_stream);
}
cc_ccache_f *vector_functions;
#endif
cci_identifier_t identifier;
+ cc_time_t last_wait_for_change_time;
} *cci_ccache_t;
/* ------------------------------------------------------------------------ */
NULL
VECTOR_FUNCTIONS_INITIALIZER,
NULL,
+ 0
};
cc_ccache_f cci_ccache_f_initializer = {
{
cc_int32 err = ccNoError;
cci_ccache_t ccache = (cci_ccache_t) in_ccache;
+ cci_stream_t request = NULL;
+ cci_stream_t reply = NULL;
if (!in_ccache) { err = cci_check_error (ccErrBadParam); }
+ if (!err) {
+ err = cci_stream_new (&request);
+ }
+
+ if (!err) {
+ err = cci_stream_write_time (request, ccache->last_wait_for_change_time);
+ }
+
if (!err) {
err = cci_ipc_send (cci_ccache_wait_for_change_msg_id,
ccache->identifier,
- NULL, NULL);
+ request,
+ &reply);
}
+
+ if (!err) {
+ err = cci_stream_read_time (reply, &ccache->last_wait_for_change_time);
+ }
+ cci_stream_release (request);
+ cci_stream_release (reply);
+
return cci_check_error (err);
}
#endif
cci_identifier_t identifier;
cc_uint32 synchronized;
+ cc_time_t last_wait_for_change_time;
} *cci_context_t;
/* ------------------------------------------------------------------------ */
NULL
VECTOR_FUNCTIONS_INITIALIZER,
NULL,
+ 0,
0
};
{
cc_int32 err = ccNoError;
cci_context_t context = (cci_context_t) in_context;
+ cci_stream_t request = NULL;
+ cci_stream_t reply = NULL;
if (!in_context) { err = cci_check_error (ccErrBadParam); }
if (!err) {
- err = cci_context_sync (context, 0);
+ err = cci_stream_new (&request);
}
if (!err) {
- err = cci_ipc_send_no_launch (cci_context_wait_for_change_msg_id,
- context->identifier,
- NULL, NULL);
+ err = cci_stream_write_time (request, context->last_wait_for_change_time);
+ }
+
+ if (!err) {
+ err = cci_context_sync (context, 1);
}
+ if (!err) {
+ err = cci_ipc_send (cci_context_wait_for_change_msg_id,
+ context->identifier,
+ request,
+ &reply);
+ }
+
+ if (!err) {
+ err = cci_stream_read_time (reply, &context->last_wait_for_change_time);
+ }
+
+ cci_stream_release (request);
+ cci_stream_release (reply);
+
return cci_check_error (err);
}
{
cc_int32 err = ccNoError;
- if (!io_cache_collection) { err = ccErrBadParam; }
-
- if (!err) {
+ if (!err && io_cache_collection) {
cci_identifier_release (io_cache_collection->identifier);
ccs_lock_state_release (io_cache_collection->lock_state);
ccs_ccache_list_release (io_cache_collection->ccaches);
cc_int32 ccs_cache_collection_changed (ccs_cache_collection_t io_cache_collection)
{
cc_int32 err = ccNoError;
+ cci_stream_t reply_data = NULL;
if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
}
}
+ if (!err) {
+ err = cci_stream_new (&reply_data);
+ }
+
+ if (!err) {
+ err = cci_stream_write_time (reply_data, io_cache_collection->last_changed_time);
+ }
+
if (!err) {
/* Loop over callbacks sending messages to them */
cc_uint64 i;
for (i = 0; !err && i < count; i++) {
ccs_callback_t callback = ccs_callback_array_object_at_index (io_cache_collection->change_callbacks, i);
- err = ccs_callback_reply_to_client (callback, NULL);
+ err = ccs_callback_reply_to_client (callback, reply_data);
if (!err) {
cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback);
break;
}
}
-
}
+ cci_stream_release (reply_data);
+
return cci_check_error (err);
}
ccs_pipe_t in_reply_pipe,
ccs_cache_collection_t io_cache_collection,
cci_stream_t in_request_data,
+ cci_stream_t io_reply_data,
cc_uint32 *out_will_block)
{
cc_int32 err = ccNoError;
- ccs_callback_t callback = NULL;
+ cc_time_t last_wait_for_change_time = 0;
+ cc_uint32 will_block = 0;
if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
if (!ccs_pipe_valid (in_reply_pipe )) { err = cci_check_error (ccErrBadParam); }
if (!out_will_block ) { err = cci_check_error (ccErrBadParam); }
if (!err) {
- err = ccs_callback_new (&callback,
- ccErrInvalidContext,
- in_client_pipe,
- in_reply_pipe,
- (ccs_callback_owner_t) io_cache_collection,
- ccs_cache_collection_invalidate_change_callback);
+ err = cci_stream_read_time (in_request_data, &last_wait_for_change_time);
}
if (!err) {
- err = ccs_callback_array_insert (io_cache_collection->change_callbacks, callback,
- ccs_callback_array_count (io_cache_collection->change_callbacks));
- if (!err) { callback = NULL; /* take ownership */ }
- }
+ if (last_wait_for_change_time < io_cache_collection->last_changed_time) {
+ err = cci_stream_write_time (io_reply_data, io_cache_collection->last_changed_time);
+
+ } else {
+ ccs_callback_t callback = NULL;
- if (!err) {
- *out_will_block = 1;
+ err = ccs_callback_new (&callback,
+ ccErrInvalidContext,
+ in_client_pipe,
+ in_reply_pipe,
+ (ccs_callback_owner_t) io_cache_collection,
+ ccs_cache_collection_invalidate_change_callback);
+
+ if (!err) {
+ err = ccs_callback_array_insert (io_cache_collection->change_callbacks, callback,
+ ccs_callback_array_count (io_cache_collection->change_callbacks));
+ if (!err) { callback = NULL; /* take ownership */ }
+
+ will_block = 1;
+ }
+
+ ccs_callback_release (callback);
+ }
}
- ccs_callback_release (callback);
+ if (!err) {
+ *out_will_block = will_block;
+ }
return cci_check_error (err);
}
} else if (in_request_name == cci_context_wait_for_change_msg_id) {
err = ccs_cache_collection_wait_for_change (in_client_pipe, in_reply_pipe,
io_cache_collection,
- in_request_data, &will_block);
+ in_request_data, reply_data,
+ &will_block);
} else if (in_request_name == cci_context_get_default_ccache_name_msg_id) {
err = ccs_cache_collection_get_default_ccache_name (io_cache_collection,
cc_int32 ccs_callback_release (ccs_callback_t io_callback)
{
cc_int32 err = ccNoError;
- ccs_client_t client = NULL;
-
- if (!io_callback) { err = cci_check_error (ccErrBadParam); }
- if (!err && io_callback->pending) {
- err = ccs_server_send_reply (io_callback->reply_pipe,
- io_callback->invalid_object_err, NULL);
-
- io_callback->pending = 0;
- }
-
- if (!err) {
- err = ccs_server_client_for_pipe (io_callback->client_pipe, &client);
- }
-
- if (!err) {
- err = ccs_client_remove_callback (client, io_callback);
- }
-
- if (!err) {
- ccs_pipe_release (io_callback->client_pipe);
- ccs_pipe_release (io_callback->reply_pipe);
- free (io_callback);
+ if (!err && io_callback) {
+ ccs_client_t client = NULL;
+
+ if (io_callback->pending) {
+ err = ccs_server_send_reply (io_callback->reply_pipe,
+ io_callback->invalid_object_err, NULL);
+
+ io_callback->pending = 0;
+ }
+
+ if (!err) {
+ err = ccs_server_client_for_pipe (io_callback->client_pipe, &client);
+ }
+
+ if (!err) {
+ err = ccs_client_remove_callback (client, io_callback);
+ }
+
+ if (!err) {
+ ccs_pipe_release (io_callback->client_pipe);
+ ccs_pipe_release (io_callback->reply_pipe);
+ free (io_callback);
+ }
}
return cci_check_error (err);
if (!err) {
if (io_callback->pending) {
+ cci_debug_printf ("%s: callback %p replying to client.", __FUNCTION__, io_callback);
+
err = ccs_server_send_reply (io_callback->reply_pipe, err, in_stream);
if (err) {
{
cc_int32 err = ccNoError;
- if (!io_ccache) { err = ccErrBadParam; }
-
- if (!err) {
+ if (!err && io_ccache) {
cci_identifier_release (io_ccache->identifier);
ccs_lock_state_release (io_ccache->lock_state);
free (io_ccache->name);
ccs_cache_collection_t io_cache_collection)
{
cc_int32 err = ccNoError;
+ cci_stream_t reply_data = NULL;
if (!io_ccache ) { err = cci_check_error (ccErrBadParam); }
if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
err = ccs_cache_collection_changed (io_cache_collection);
}
+ if (!err) {
+ err = cci_stream_new (&reply_data);
+ }
+
+ if (!err) {
+ err = cci_stream_write_time (reply_data, io_ccache->last_changed_time);
+ }
+
if (!err) {
/* Loop over callbacks sending messages to them */
cc_uint64 i;
for (i = 0; !err && i < count; i++) {
ccs_callback_t callback = ccs_callback_array_object_at_index (io_ccache->change_callbacks, i);
- err = ccs_callback_reply_to_client (callback, NULL);
+ err = ccs_callback_reply_to_client (callback, reply_data);
if (!err) {
cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback);
break;
}
}
-
}
+ cci_stream_release (reply_data);
+
return cci_check_error (err);
}
ccs_ccache_t io_ccache,
ccs_cache_collection_t io_cache_collection,
cci_stream_t in_request_data,
+ cci_stream_t io_reply_data,
cc_uint32 *out_will_block)
{
cc_int32 err = ccNoError;
- ccs_callback_t callback = NULL;
+ cc_time_t last_wait_for_change_time = 0;
+ cc_uint32 will_block = 0;
if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
if (!ccs_pipe_valid (in_reply_pipe )) { err = cci_check_error (ccErrBadParam); }
if (!out_will_block ) { err = cci_check_error (ccErrBadParam); }
if (!err) {
- err = ccs_callback_new (&callback,
- ccErrInvalidCCache,
- in_client_pipe,
- in_reply_pipe,
- (ccs_callback_owner_t) io_ccache,
- ccs_ccache_invalidate_change_callback);
+ err = cci_stream_read_time (in_request_data, &last_wait_for_change_time);
}
if (!err) {
- err = ccs_callback_array_insert (io_ccache->change_callbacks, callback,
- ccs_callback_array_count (io_ccache->change_callbacks));
- if (!err) { callback = NULL; /* take ownership */ }
+ if (last_wait_for_change_time < io_ccache->last_changed_time) {
+ err = cci_stream_write_time (io_reply_data, io_ccache->last_changed_time);
+
+ } else {
+ ccs_callback_t callback = NULL;
+
+ err = ccs_callback_new (&callback,
+ ccErrInvalidCCache,
+ in_client_pipe,
+ in_reply_pipe,
+ (ccs_callback_owner_t) io_ccache,
+ ccs_ccache_invalidate_change_callback);
+
+ if (!err) {
+ err = ccs_callback_array_insert (io_ccache->change_callbacks, callback,
+ ccs_callback_array_count (io_ccache->change_callbacks));
+ if (!err) { callback = NULL; /* take ownership */ }
+
+ will_block = 1;
+ }
+
+ ccs_callback_release (callback);
+ }
}
-
+
if (!err) {
- *out_will_block = 1;
+ *out_will_block = will_block;
}
- ccs_callback_release (callback);
-
return cci_check_error (err);
}
} else if (in_request_name == cci_ccache_wait_for_change_msg_id) {
err = ccs_ccache_wait_for_change (in_client_pipe, in_reply_pipe,
io_ccache, io_cache_collection,
- in_request_data, &will_block);
+ in_request_data, reply_data,
+ &will_block);
} else if (in_request_name == cci_ccache_get_kdc_time_offset_msg_id) {
err = ccs_ccache_get_kdc_time_offset (io_ccache, io_cache_collection,
{
cc_int32 err = ccNoError;
- if (!io_client) { err = cci_check_error (ccErrBadParam); }
-
- if (!err) {
- ccs_callbackref_array_release (io_client->callbacks);
+ if (!err && io_client) {
+ cc_uint64 i;
+ cc_uint64 lock_count = ccs_callbackref_array_count (io_client->callbacks);
+
+ for (i = 0; !err && i < lock_count; i++) {
+ ccs_callback_t callback = ccs_callbackref_array_object_at_index (io_client->callbacks, i);
+
+ cci_debug_printf ("%s: Invalidating callback reference %p.", __FUNCTION__, callback);
+ ccs_callback_invalidate (callback);
+ }
+
+ ccs_callbackref_array_release (io_client->callbacks);
ccs_pipe_release (io_client->client_pipe);
- free (io_client);
+ free (io_client);
}
return cci_check_error (err);
ccs_callback_t callback = ccs_callbackref_array_object_at_index (io_client->callbacks, i);
if (callback == in_callback) {
- err = ccs_callback_invalidate (callback);
-
- if (!err) {
- cci_debug_printf ("%s: Removing callback reference %p.",
- __FUNCTION__, callback);
- err = ccs_callbackref_array_remove (io_client->callbacks, i);
- break;
- }
+ cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback);
+ err = ccs_callbackref_array_remove (io_client->callbacks, i);
+ break;
}
}
}
{
cc_int32 err = ccNoError;
- if (in_client ) { err = cci_check_error (ccErrBadParam); }
- if (in_pipe ) { err = cci_check_error (ccErrBadParam); }
- if (out_uses_pipe) { err = cci_check_error (ccErrBadParam); }
+ if (!in_client ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_pipe ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_uses_pipe) { err = cci_check_error (ccErrBadParam); }
if (!err) {
*out_uses_pipe = (in_client->client_pipe == in_pipe);
{
cc_int32 err = ccNoError;
- if (!io_credentials) { err = ccErrBadParam; }
-
- if (!err) {
+ if (!err && io_credentials) {
cci_cred_union_release (io_credentials->cred_union);
cci_identifier_release (io_credentials->identifier);
free (io_credentials);
{
cc_int32 err = ccNoError;
- if (!io_list) { err = ccErrBadParam; }
-
- if (!err) {
+ if (!err && io_list) {
cc_uint64 i;
for (i = 0; i < cci_array_count (io_list->iterators); i++) {
{
cc_int32 err = ccNoError;
- if (!io_list_iterator) { err = ccErrBadParam; }
-
- if (!err) {
+ if (!err && io_list_iterator) {
cc_uint64 i = 0;
if (ccs_list_find_iterator_index (io_list_iterator->list,
{
cc_int32 err = ccNoError;
- if (!io_lock) { err = cci_check_error (ccErrBadParam); }
-
- if (!err) {
+ if (!err && io_lock) {
free (io_lock->callback);
free (io_lock);
}
{
cc_int32 err = ccNoError;
- if (!io_lock_state) { err = ccErrBadParam; }
-
- if (!err) {
+ if (!err && io_lock_state) {
ccs_lock_array_release (io_lock_state->locks);
free (io_lock_state);
}