ubus_parse_msg(hdr->data);
- if (!attrbuf[UBUS_ATTR_METHOD] || !attrbuf[UBUS_ATTR_OBJID]) {
+ if (!attrbuf[UBUS_ATTR_OBJID])
+ return;
+
+ objid = blob_get_int32(attrbuf[UBUS_ATTR_OBJID]);
+
+ if (!attrbuf[UBUS_ATTR_METHOD]) {
ret = UBUS_STATUS_INVALID_ARGUMENT;
goto send;
}
- objid = blob_get_int32(attrbuf[UBUS_ATTR_OBJID]);
obj = avl_find_element(&ctx->objects, &objid, obj, avl);
if (!obj) {
ret = UBUS_STATUS_NOT_FOUND;
while (get_next_msg(ctx, false))
ubus_process_msg(ctx, hdr);
+
+ if (u->eof)
+ ctx->connection_lost(ctx);
}
int ubus_complete_request(struct ubus_context *ctx, struct ubus_request *req)
return 0;
}
+void ubus_default_connection_lost(struct ubus_context *ctx)
+{
+ if (ctx->sock.registered)
+ uloop_end();
+}
+
struct ubus_context *ubus_connect(const char *path)
{
struct ubus_context *ctx;
ctx->local_id = hdr.hdr.peer;
free(buf);
+ ctx->connection_lost = ubus_default_connection_lost;
+
INIT_LIST_HEAD(&ctx->requests);
avl_init(&ctx->objects, ubus_cmp_id, false, NULL);