From: Felix Fietkau Date: Thu, 27 Oct 2011 11:46:05 +0000 (+0200) Subject: libubus: fix recursive synchrnonous invoke commands X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f07b02b56089660f00b5070a96e76c43063a11ec;p=oweals%2Fubus.git libubus: fix recursive synchrnonous invoke commands --- diff --git a/libubus.c b/libubus.c index f3859b7..94b0044 100644 --- a/libubus.c +++ b/libubus.c @@ -282,7 +282,7 @@ static int ubus_process_req_status(struct ubus_request *req, struct ubus_msghdr int ret = UBUS_STATUS_INVALID_ARGUMENT; if (!list_empty(&req->list)) - list_del(&req->list); + list_del_init(&req->list); ubus_get_status(hdr, &ret); req->peer = hdr->peer; @@ -417,7 +417,7 @@ void ubus_abort_request(struct ubus_context *ctx, struct ubus_request *req) req->cancelled = true; ubus_process_req_data(req); - list_del(&req->list); + list_del_init(&req->list); } void ubus_complete_request_async(struct ubus_context *ctx, struct ubus_request *req) @@ -469,7 +469,6 @@ int ubus_complete_request(struct ubus_context *ctx, struct ubus_request *req, struct ubus_sync_req_cb cb; ubus_complete_handler_t complete_cb = req->complete_cb; bool registered = ctx->sock.registered; - bool cancelled = uloop_cancelled; int status = UBUS_STATUS_NO_DATA; if (!registered) { @@ -487,7 +486,12 @@ int ubus_complete_request(struct ubus_context *ctx, struct ubus_request *req, ubus_complete_request_async(ctx, req); req->complete_cb = ubus_sync_req_cb; - uloop_run(); + while (!req->status_msg) { + bool cancelled = uloop_cancelled; + uloop_cancelled = false; + uloop_run(); + uloop_cancelled = cancelled; + } if (timeout) uloop_timeout_cancel(&cb.timeout); @@ -499,7 +503,6 @@ int ubus_complete_request(struct ubus_context *ctx, struct ubus_request *req, if (req->complete_cb) req->complete_cb(req, status); - uloop_cancelled = cancelled; if (!registered) uloop_fd_delete(&ctx->sock);