X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=ubusd_proto.c;h=caede10fefc9e3d7d09bad2e13673e785cd23a60;hp=811aa79f478782544e2ee236e09da0a21832a468;hb=ba607d976b77c40162637d354fd8e1560384a66d;hpb=37cc5d2f25c162c1e125922e91bbc741e2e4a6d1 diff --git a/ubusd_proto.c b/ubusd_proto.c index 811aa79..caede10 100644 --- a/ubusd_proto.c +++ b/ubusd_proto.c @@ -158,14 +158,13 @@ static void ubusd_send_obj(struct ubus_client *cl, struct ubus_msg_buf *ub, stru blob_buf_init(&b, 0); - if (obj->path.key) - blob_put_string(&b, UBUS_ATTR_OBJPATH, obj->path.key); + blob_put_string(&b, UBUS_ATTR_OBJPATH, obj->path.key); blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id); blob_put_int32(&b, UBUS_ATTR_OBJTYPE, obj->type->id.id); s = blob_nest_start(&b, UBUS_ATTR_SIGNATURE); list_for_each_entry(m, &obj->type->methods, list) - blob_put(&b, blob_id(m->data), blob_data(m->data), blob_len(m->data)); + blobmsg_add_blob(&b, m->data); blob_nest_end(&b, s); ubus_send_msg_from_blob(cl, ub, UBUS_MSG_DATA); @@ -245,7 +244,7 @@ static int ubusd_handle_invoke(struct ubus_client *cl, struct ubus_msg_buf *ub, method = blob_data(attr[UBUS_ATTR_METHOD]); if (!obj->client) - return obj->recv_msg(cl, method, attr[UBUS_ATTR_DATA]); + return obj->recv_msg(cl, ub, method, attr[UBUS_ATTR_DATA]); ub->hdr.peer = cl->id.id; blob_buf_init(&b, 0); @@ -487,6 +486,9 @@ void ubus_notify_subscription(struct ubus_object *obj) blob_put_int8(&b, UBUS_ATTR_ACTIVE, active); ub = ubus_msg_from_blob(false); + if (!ub) + return; + ubus_msg_init(ub, UBUS_MSG_NOTIFY, ++obj->invoke_seq, 0); ubus_msg_send(obj->client, ub, true); } @@ -500,13 +502,15 @@ void ubus_notify_unsubscribe(struct ubus_subscription *s) blob_put_int32(&b, UBUS_ATTR_TARGET, s->target->id.id); ub = ubus_msg_from_blob(false); - ubus_msg_init(ub, UBUS_MSG_UNSUBSCRIBE, ++s->subscriber->invoke_seq, 0); - ubus_msg_send(s->subscriber->client, ub, true); + if (ub != NULL) { + ubus_msg_init(ub, UBUS_MSG_UNSUBSCRIBE, ++s->subscriber->invoke_seq, 0); + ubus_msg_send(s->subscriber->client, ub, true); + } ubus_unsubscribe(s); } -static void __init ubusd_proto_init(void) +static void __constructor ubusd_proto_init(void) { ubus_init_id_tree(&clients);