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

Alexandru Ardelean ardeleanalex at gmail.com
Wed Aug 6 07:42:34 EDT 2014


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

diff --git a/libubus-io.c b/libubus-io.c
index 31dad27..87569a5 100644
--- a/libubus-io.c
+++ b/libubus-io.c
@@ -256,12 +256,10 @@ 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 &&
+	    ctx->msgbuf_data_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