[OpenWrt-Devel] [PATCH][RESEND] libubus: fix msgbuf reduction logic during receive

Alexandru Ardelean ardeleanalex at gmail.com
Thu Aug 7 01:32:53 EDT 2014


Signed-off-by: Alexandru Ardelean <aa at ocedo.com>
---
 libubus-io.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libubus-io.c b/libubus-io.c
index 31dad27..2b25696 100644
--- a/libubus-io.c
+++ b/libubus-io.c
@@ -256,12 +256,9 @@ static bool get_next_msg(struct ubus_context *ctx, int *recv_fd)
 	len = blob_raw_len(&hdrbuf.data);
 	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
+	if (ctx->msgbuf_reduction_counter > 0 && len < UBUS_MSG_CHUNK_SIZE) {
+		len = (0 == --ctx->msgbuf_reduction_counter) ? UBUS_MSG_CHUNK_SIZE : -1;
 	} else
 		len = -1;
 
-- 
1.8.4.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list