Beispiel #1
0
static cc_int32 ccs_ccache_wait_for_change (ccs_pipe_t              in_client_pipe,
					    ccs_pipe_t              in_reply_pipe,
					    ccs_ccache_t            io_ccache,
					    ccs_cache_collection_t  io_cache_collection,
					    k5_ipc_stream            in_request_data,
					    k5_ipc_stream            io_reply_data,
					    cc_uint32              *out_will_block)
{
    cc_int32 err = ccNoError;
    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 (!io_ccache                      ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection            ) { err = cci_check_error (ccErrBadParam); }
    if (!in_request_data                ) { err = cci_check_error (ccErrBadParam); }
    if (!out_will_block                 ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = krb5int_ipc_stream_read_time (in_request_data, &last_wait_for_change_time);
    }

    if (!err) {
	if (last_wait_for_change_time < io_ccache->last_changed_time) {
	    cci_debug_printf ("%s returning immediately", __FUNCTION__);
	    err = krb5int_ipc_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 */ }

		cci_debug_printf ("%s blocking", __FUNCTION__);
		will_block = 1;
	    }

	    ccs_callback_release (callback);
	}
    }

    if (!err) {
	*out_will_block = will_block;
    }

    return cci_check_error (err);
}
Beispiel #2
0
cc_int32 ccs_callback_new (ccs_callback_t                  *out_callback,
			   cc_int32                         in_invalid_object_err,
			   ccs_pipe_t                       in_client_pipe,
			   ccs_pipe_t                       in_reply_pipe,
			   ccs_callback_owner_t             in_owner,
			   ccs_callback_owner_invalidate_t  in_owner_invalidate_function)
{
    cc_int32 err = ccNoError;
    ccs_callback_t callback = NULL;
    ccs_client_t client = NULL;
    
    if (!out_callback                   ) { err = cci_check_error (ccErrBadParam); }
    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 (!in_owner                       ) { err = cci_check_error (ccErrBadParam); }
    if (!in_owner_invalidate_function   ) { err = cci_check_error (ccErrBadParam); }
    
    if (!err) {
        callback = malloc (sizeof (*callback));
        if (callback) { 
            *callback = ccs_callback_initializer;
        } else {
            err = cci_check_error (ccErrNoMem); 
        }
    }
    
    if (!err) {
        err = ccs_server_client_for_pipe (in_client_pipe, &client);
    }
    
    if (!err) {
	err = ccs_pipe_copy (&callback->client_pipe, in_client_pipe);
    }
    
    if (!err) {
	err = ccs_pipe_copy (&callback->reply_pipe, in_reply_pipe);
    }
    
    if (!err) {
        callback->client_pipe = in_client_pipe;
        callback->reply_pipe = in_reply_pipe;
        callback->invalid_object_err = in_invalid_object_err;
        callback->owner = in_owner;
        callback->owner_invalidate = in_owner_invalidate_function;
    
        err = ccs_client_add_callback (client, callback);
    }
     
    if (!err) {
        *out_callback = callback;
        callback = NULL;
    }
    
    ccs_callback_release (callback);
    
    return cci_check_error (err);    
}
Beispiel #3
0
cc_int32 ccs_lock_release (ccs_lock_t io_lock)
{
    cc_int32 err = ccNoError;

    if (!err && io_lock) {
	ccs_callback_release (io_lock->callback);
        free (io_lock);
    }

    return cci_check_error (err);
}
Beispiel #4
0
static cc_int32 ccs_callback_object_release (cci_array_object_t io_callback)
{
    return cci_check_error (ccs_callback_release ((ccs_callback_t) io_callback));
}