libubus: fix writev_retry() function when writing large packets
[project/ubus.git] / libubus-obj.c
index ed18ca9..47bdb0a 100644 (file)
@@ -27,7 +27,8 @@ ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr,
                return;
 
        s = container_of(obj, struct ubus_subscriber, obj);
-       s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET]));
+       if (s->remove_cb)
+               s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET]));
 }
 
 static void
@@ -45,7 +46,9 @@ static void
 ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr,
                    struct ubus_object *obj, struct blob_attr **attrbuf)
 {
-       struct ubus_request_data req = {};
+       struct ubus_request_data req = {
+               .fd = -1,
+       };
        int method;
        int ret;
        bool no_reply = false;
@@ -96,7 +99,7 @@ void __hidden ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr
        struct ubus_object *obj;
        uint32_t objid;
 
-       attrbuf = ubus_parse_msg(hdr->data);
+       attrbuf = ubus_parse_msg(ubus_msghdr_data(hdr));
        if (!attrbuf[UBUS_ATTR_OBJID])
                return;
 
@@ -143,8 +146,12 @@ static void ubus_push_method_data(const struct ubus_method *m)
 
        mtbl = blobmsg_open_table(&b, m->name);
 
-       for (i = 0; i < m->n_policy; i++)
+       for (i = 0; i < m->n_policy; i++) {
+               if (m->mask && !(m->mask & (1 << i)))
+                       continue;
+
                blobmsg_add_u32(&b, m->policy[i].name, m->policy[i].type);
+       }
 
        blobmsg_close_table(&b, mtbl);
 }