libubus: remove ubus_msghdr_data() by passing in the right data structure pointer
[project/ubus.git] / libubus-io.c
index 3280e41..55ddff5 100644 (file)
@@ -254,15 +254,11 @@ static bool get_next_msg(struct ubus_context *ctx, int *recv_fd)
                return false;
 
        len = blob_raw_len(&hdrbuf.data);
                return false;
 
        len = blob_raw_len(&hdrbuf.data);
-       if (len > ctx->msgbuf_data_len) {
+       if (len > ctx->msgbuf_data_len)
                ctx->msgbuf_reduction_counter = UBUS_MSGBUF_REDUCTION_INTERVAL;
                ctx->msgbuf_reduction_counter = UBUS_MSGBUF_REDUCTION_INTERVAL;
-       } else if (ctx->msgbuf_data_len > UBUS_MSG_CHUNK_SIZE) {
-               if (ctx->msgbuf_reduction_counter > 0) {
-                       len = -1;
-                       --ctx->msgbuf_reduction_counter;
-               } else
-                       len = UBUS_MSG_CHUNK_SIZE;
-       } else
+       else if (ctx->msgbuf_reduction_counter > 0 && len < UBUS_MSG_CHUNK_SIZE)
+               len = !--ctx->msgbuf_reduction_counter ? UBUS_MSG_CHUNK_SIZE : -1;
+       else
                len = -1;
 
        if (len > -1) {
                len = -1;
 
        if (len > -1) {
@@ -287,11 +283,10 @@ static bool get_next_msg(struct ubus_context *ctx, int *recv_fd)
 void __hidden ubus_handle_data(struct uloop_fd *u, unsigned int events)
 {
        struct ubus_context *ctx = container_of(u, struct ubus_context, sock);
 void __hidden ubus_handle_data(struct uloop_fd *u, unsigned int events)
 {
        struct ubus_context *ctx = container_of(u, struct ubus_context, sock);
-       struct ubus_msghdr *hdr = &ctx->msgbuf.hdr;
        int recv_fd = -1;
 
        while (get_next_msg(ctx, &recv_fd)) {
        int recv_fd = -1;
 
        while (get_next_msg(ctx, &recv_fd)) {
-               ubus_process_msg(ctx, hdr, recv_fd);
+               ubus_process_msg(ctx, &ctx->msgbuf, recv_fd);
                if (uloop_cancelled)
                        break;
        }
                if (uloop_cancelled)
                        break;
        }