mrp_res_resource_set_t *rset;
- printf("\nResource event (request no %u):\n", seqno);
+ mrp_log_info("Resource event (request no %u):", seqno);
if (!fetch_resource_set_id(msg, pcursor, &rset_id) ||
!fetch_resource_set_state(msg, pcursor, &state) ||
!fetch_resource_set_mask(msg, pcursor, 0, &grant) ||
!fetch_resource_set_mask(msg, pcursor, 1, &advice)) {
- printf("malformed 0.2\n");
+ mrp_log_error("failed to fetch data from message");
goto malformed;
}
/* Update our "master copy" of the resource set. */
- printf("going to get rset of id %d\n", rset_id);
rset = mrp_htbl_lookup(cx->priv->rset_mapping, u_to_p(rset_id));
if (!rset) {
- printf("resource event before creating the resource set!\n");
+ mrp_log_error("resource event outside the resource set lifecycle");
goto malformed;
}
- printf("resource set %p id: %u\n", rset, rset->priv->id);
-
switch (state) {
case RESPROTO_RELEASE:
rset->state = MRP_RES_RESOURCE_LOST;
mrp_res_resource_t *res = NULL;
- printf("iterating through the resources...\n");
-
if ((tag != RESPROTO_RESOURCE_ID || type != MRP_MSG_FIELD_UINT32) ||
- !fetch_resource_name(msg, pcursor, &resnam)) {
- printf("malformed 1\n");
+ !fetch_resource_name(msg, pcursor, &resnam)) {
+ mrp_log_error("failed to read resource from message");
goto malformed;
}
res = get_resource_by_name(rset, resnam);
if (!res) {
- printf("malformed 2\n");
+ mrp_log_error("resource doesn't exist in resource set");
goto malformed;
}
n_attrs = fetch_attribute_array(msg, pcursor, ATTRIBUTE_MAX + 1, attrs);
if (n_attrs < 0) {
- printf("malformed 3\n");
+ mrp_log_error("failed to read attributes from message");
goto malformed;
}
fetch_request(msg, &cursor, &req) < 0)
goto error;
- printf("received message %d for %p\n", req, cx);
+ mrp_log_info("received message %d for %p", req, cx);
switch (req) {
case RESPROTO_QUERY_RESOURCES:
- printf("received QUERY_RESOURCES response\n");
+ mrp_log_info("received QUERY_RESOURCES response");
cx->priv->master_resource_set =
resource_query_response(msg, &cursor);
break;
case RESPROTO_QUERY_CLASSES:
- printf("received QUERY_CLASSES response\n");
+ mrp_log_info("received QUERY_CLASSES response");
cx->priv->master_classes = class_query_response(msg, &cursor);
if (!cx->priv->master_classes)
mrp_res_resource_set_t *rset = NULL;
mrp_list_hook_t *p, *n;
- printf("received CREATE_RESOURCE_SET response\n");
+ mrp_log_info("received CREATE_RESOURCE_SET response");
/* get the correct resource set from the pending_sets list */
if (!create_resource_set_response(msg, rset, &cursor))
goto error;
- printf("inserting rset %p of id %d\n", rset, rset->priv->id);
mrp_htbl_insert(cx->priv->rset_mapping,
u_to_p(rset->priv->id), rset);
{
mrp_res_resource_set_t *rset;
- printf("received ACQUIRE_RESOURCE_SET response\n");
+ mrp_log_info("received ACQUIRE_RESOURCE_SET response");
rset = acquire_resource_set_response(msg, cx, &cursor);
case RESPROTO_RELEASE_RESOURCE_SET:
{
mrp_res_resource_set_t *rset;
- printf("received RELEASE_RESOURCE_SET response\n");
+ mrp_log_info("received RELEASE_RESOURCE_SET response");
rset = acquire_resource_set_response(msg, cx, &cursor);
break;
}
case RESPROTO_RESOURCES_EVENT:
- printf("received RESOURCES_EVENT response\n");
+ mrp_log_info("received RESOURCES_EVENT response");
resource_event(msg, cx, seqno, &cursor);
break;
case RESPROTO_DESTROY_RESOURCE_SET:
- /* TODO */
+ mrp_log_info("received DESTROY_RESOURCE_SET response");
+ /* TODO? */
break;
default:
break;
return;
error:
- printf("error processing a message from Murphy\n");
+ mrp_log_error("error processing a message from the server");
cx->priv->cb(cx, MRP_RES_ERROR_INTERNAL, cx->priv->user_data);
}
MRP_UNUSED(transp);
MRP_UNUSED(error);
- printf("connection closed for %p\n", cx);
+ mrp_log_error("connection closed for %p", cx);
cx->priv->connected = FALSE;
}
static void htbl_free_rset_mapping(void *key, void *object)
{
#if 0
- printf("> htbl_free_rset_mapping(%d, %p)\n", p_to_u(key), object);
+ mrp_log_info("> htbl_free_rset_mapping(%d, %p)", p_to_u(key), object);
#else
MRP_UNUSED(key);
#endif
error:
- printf("Error connecting to Murphy!\n");
+ mrp_log_error("error connecting to server");
destroy_context(cx);
return NULL;
void mrp_res_destroy(mrp_res_context_t *cx)
{
- printf("> mrp_res_destroy\n");
destroy_context(cx);
}
#include "attribute.h"
#include "message.h"
-#ifndef NO_DEBUG
void print_resource(mrp_res_resource_t *res)
{
- printf(" resource '%s' : %smandatory, %sshared\n",
+ mrp_log_info(" resource '%s' : %smandatory, %sshared",
res->name, res->priv->mandatory ? " " : "not ",
res->priv->shared ? "" : "not ");
}
+
void print_resource_set(mrp_res_resource_set_t *rset)
{
int i;
mrp_res_resource_t *res;
- printf("Resource set %i (%s):\n", rset->priv->id, rset->application_class);
+ mrp_log_info("Resource set %i (%s):", rset->priv->id, rset->application_class);
for (i = 0; i < rset->priv->num_resources; i++) {
res = rset->priv->resources[i];
print_resource(res);
}
}
-#endif
void increase_ref(mrp_res_context_t *cx,
return;
rset->priv->internal_ref_count++;
-
- printf("rset %p ref count increased to %d\n",
- rset, rset->priv->internal_ref_count);
}
-static int destroy_resource_set(mrp_res_context_t *cx,
+static int destroy_resource_set_request(mrp_res_context_t *cx,
mrp_res_resource_set_t *rset)
{
mrp_msg_t *msg = NULL;
}
-
-
void decrease_ref(mrp_res_context_t *cx,
mrp_res_resource_set_t *rset)
{
rset->priv->internal_ref_count--;
- printf("rset %p ref count decreased to %d\n",
- rset, rset->priv->internal_ref_count);
-
if (rset->priv->internal_ref_count == 0) {
- printf("delete the server resource set now\n");
- destroy_resource_set(cx, rset);
+ mrp_log_info("delete the server resource set now");
+ destroy_resource_set_request(cx, rset);
mrp_htbl_remove(cx->priv->rset_mapping,
u_to_p(rset->priv->id), FALSE);
mrp_htbl_remove(cx->priv->internal_rset_mapping,
for (i = 0; i < rset->priv->num_resources; i++) {
mrp_res_resource_t *res = rset->priv->resources[i];
- printf(" comparing '%s' with '%s'\n",
- name, res->name ? res->name : "NULL");
if (strcmp(res->name, name) == 0) {
return res;
}
{
int i;
- printf("> free resource set %p\n", rset);
-
if (!rset)
return;
if (!rs)
return;
- printf("> delete_resource_set (%p)\n", rs);
-
if (cx && rs->priv) {
/* check if the resource set being deleted is a library resource set */
mrp_res_resource_set_t *internal_rset = mrp_htbl_lookup(
{
mrp_res_resource_t *copy;
- printf("> resource_copy\n");
-
copy = mrp_allocz(sizeof(mrp_res_resource_t));
if (!copy)
return copy;
error:
- printf("resource_copy error\n");
+ mrp_log_error("failed to copy resource");
if (copy) {
mrp_free((void *) copy->name);
copy = mrp_allocz(sizeof(mrp_res_resource_set_t));
- printf("> resource_set_copy (%p -> %p)\n", original, copy);
-
if (!copy)
goto error;
mrp_htbl_insert(cx->priv->internal_rset_mapping,
u_to_p(internal->priv->internal_id), internal);
- printf("< create_resource_set (%p, internal %p)\n", rs, internal);
-
return rs;
error:
return res;
error:
- printf("mrp_res_create_resource error\n");
+ mrp_log_error("mrp_res_create_resource error");
free_resource(res);
return NULL;
{
mrp_res_resource_set_t *internal_set = NULL;
- printf("> mrp_release_resources (rset %d at %p)\n",
- rset->priv->id, rset);
-
- print_resource_set(rset);
-
if (!cx->priv->connected)
goto error;
return release_resource_set_request(cx, internal_set);
error:
+ mrp_log_error("mrp_release_resources error");
+
return -1;
}
rset = mrp_htbl_lookup(cx->priv->internal_rset_mapping,
u_to_p(original->priv->internal_id));
- printf("> mrp_acquire_resources (client %p, internal %p)\n",
- original, rset);
-
if (!rset)
goto error;
return 0;
error:
+ mrp_log_error("mrp_res_acquire_resource_set error");
+
mrp_msg_unref(msg);
return -1;
}