- ubus_complete_handler_t cb = req->complete_cb;
-
- if (!cb)
- return;
-
- req->complete_cb = NULL;
- cb(req, req->status_code);
-}
-
-static int ubus_process_req_status(struct ubus_request *req, struct ubus_msghdr *hdr)
-{
- int ret = UBUS_STATUS_INVALID_ARGUMENT;
-
- if (!list_empty(&req->list))
- list_del_init(&req->list);
-
- ubus_get_status(hdr, &ret);
- req->peer = hdr->peer;
- req->status_msg = true;
- req->status_code = ret;
- if (!req->blocked)
- ubus_req_complete_cb(req);
-
- return ret;
-}
-
-static void ubus_req_data(struct ubus_request *req, struct ubus_msghdr *hdr)
-{
- struct ubus_pending_data *data;
- int len;
-
- if (!req->blocked) {
- req->blocked = true;
- req_data_cb(req, hdr->type, hdr->data);
- ubus_process_req_data(req);
- req->blocked = false;
-
- if (req->status_msg)
- ubus_req_complete_cb(req);
-
- return;
- }
-
- len = blob_raw_len(hdr->data);
- data = calloc(1, sizeof(*data) + len);
- if (!data)
- return;
-
- data->type = hdr->type;
- memcpy(data->data, hdr->data, len);
- list_add(&data->list, &req->pending);
-}
-
-static struct ubus_request *ubus_find_request(struct ubus_context *ctx, uint32_t seq, uint32_t peer)
-{
- struct ubus_request *req;
-
- list_for_each_entry(req, &ctx->requests, list) {
- if (seq != req->seq || peer != req->peer)
- continue;
-
- return req;
- }
- return NULL;
-}
-
-void ubus_complete_deferred_request(struct ubus_context *ctx, struct ubus_request_data *req, int ret)
-{
- blob_buf_init(&b, 0);
- blob_put_int32(&b, UBUS_ATTR_STATUS, ret);
- blob_put_int32(&b, UBUS_ATTR_OBJID, req->object);
- ubus_send_msg(ctx, req->seq, b.head, UBUS_MSG_STATUS, req->peer);
-}
-
-void __hidden ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr *hdr)
-{
- struct ubus_pending_invoke *pending;
- struct ubus_request *req;