From 6280cbaf0966928c4f83b925fb5b94c3ecb1936e Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 7 Aug 2014 04:32:53 +0000 Subject: [PATCH] libubus: fix msgbuf reduction logic during receive Signed-off-by: Alexandru Ardelean Signed-off-by: Felix Fietkau --- libubus-io.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libubus-io.c b/libubus-io.c index 3280e41..ba22dcb 100644 --- a/libubus-io.c +++ b/libubus-io.c @@ -254,15 +254,11 @@ static bool get_next_msg(struct ubus_context *ctx, int *recv_fd) 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; - } 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) { -- 2.30.2