}
-static int priv_res_to_mrp_res(uint32_t id, resource_def_t *src, mrp_res_resource_t *dst)
+static int priv_res_to_mrp_res(uint32_t id, resource_def_t *src, mrp_res_resource_t *dst,
+ mrp_res_resource_set_t *set)
{
dst->name = mrp_strdup(src->name);
dst->state = MRP_RES_RESOURCE_LOST;
dst->priv->num_attributes = src->num_attrs;
dst->priv->attrs = src->attrs;
+ dst->priv->set = set;
return 0;
}
-mrp_res_resource_set_t *resource_query_response(mrp_msg_t *msg,
- void **pcursor)
+mrp_res_resource_set_t *resource_query_response(mrp_res_context_t *cx,
+ mrp_msg_t *msg, void **pcursor)
{
int status;
uint32_t dim, i;
resource_def_t *src;
mrp_res_resource_set_t *arr = NULL;
+ if (!cx)
+ goto failed;
+
if (!fetch_status(msg, pcursor, &status))
goto failed;
arr->application_class = NULL;
arr->state = MRP_RES_RESOURCE_LOST;
+ arr->priv->cx = cx;
arr->priv->num_resources = dim;
arr->priv->resources = mrp_allocz_array(mrp_res_resource_t *, dim);
arr->priv->num_resources = i;
goto failed;
}
- priv_res_to_mrp_res(i, src, arr->priv->resources[i]);
+ priv_res_to_mrp_res(i, src, arr->priv->resources[i], arr);
}
}
/* handling of the message responses */
-mrp_res_resource_set_t *resource_query_response(mrp_msg_t *msg,
- void **pcursor);
+mrp_res_resource_set_t *resource_query_response(mrp_res_context_t *cx,
+ mrp_msg_t *msg, void **pcursor);
mrp_res_string_array_t *class_query_response(mrp_msg_t *msg, void **pcursor);
struct mrp_res_resource_set_private_s {
mrp_res_resource_set_t *pub; /* composition */
+ mrp_res_context_t *cx; /* the context of this resource set */
uint32_t id; /* id given by the server */
uint32_t internal_id; /* id for checking identity */
uint32_t internal_ref_count;
mrp_res_info("received QUERY_RESOURCES response");
cx->priv->master_resource_set =
- resource_query_response(msg, &cursor);
+ resource_query_response(cx, msg, &cursor);
if (!cx->priv->master_resource_set)
goto error;
break;
rs->application_class = mrp_strdup(klass);
rs->priv->pub = rs;
+ rs->priv->cx = cx;
rs->priv->id = 0;
rs->priv->internal_id = cx->priv->next_internal_id++;
rs->priv->seqno = 0;
res->priv->mandatory = mandatory;
res->priv->shared = shared;
res->priv->pub = res;
+ res->priv->set = set;
/* copy the attributes with the default values */
res->priv->attrs = mrp_attribute_array_dup(proto->priv->num_attributes,