ubus: make libubus ready for linking into C++
[project/ubus.git] / libubus.c
index 846ae83bcc1216f32067b0c771d8053d9190a33b..91f317c59867e57005618c3a94d835ff8d1d81fb 100644 (file)
--- a/libubus.c
+++ b/libubus.c
@@ -115,10 +115,12 @@ ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd)
 static void ubus_process_pending_msg(struct uloop_timeout *timeout)
 {
        struct ubus_context *ctx = container_of(timeout, struct ubus_context, pending_timer);
-       struct ubus_pending_msg *pending;
+       struct ubus_pending_msg *pending, *tmp;
+
+       list_for_each_entry_safe(pending, tmp, &ctx->pending, list) {
+               if (ctx->stack_depth)
+                       break;
 
-       while (!ctx->stack_depth && !list_empty(&ctx->pending)) {
-               pending = list_first_entry(&ctx->pending, struct ubus_pending_msg, list);
                list_del(&pending->list);
                ubus_process_msg(ctx, &pending->hdr, -1);
                free(pending);
@@ -137,7 +139,7 @@ static void ubus_lookup_cb(struct ubus_request *ureq, int type, struct blob_attr
        struct blob_attr **attr;
 
        req = container_of(ureq, struct ubus_lookup_request, req);
-       attr = ubus_parse_msg(msg);
+       attr = ubus_parse_msg(msg, blob_raw_len(msg));
 
        if (!attr[UBUS_ATTR_OBJID] || !attr[UBUS_ATTR_OBJPATH] ||
            !attr[UBUS_ATTR_OBJTYPE])
@@ -173,7 +175,7 @@ static void ubus_lookup_id_cb(struct ubus_request *req, int type, struct blob_at
        struct blob_attr **attr;
        uint32_t *id = req->priv;
 
-       attr = ubus_parse_msg(msg);
+       attr = ubus_parse_msg(msg, blob_raw_len(msg));
 
        if (!attr[UBUS_ATTR_OBJID])
                return;