summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-08-12 12:35:19 +0200
committerPetr Štetiar <ynezz@true.cz>2022-02-15 18:10:16 +0100
commitedda23fd018034493168ba67159b20d27570082b (patch)
treeab238e829a36e2cd0af13f2930f5687f73aa5d9b
parentc3f3e194870973a888cabc7129f6f8ec0c3cccee (diff)
downloadubus-edda23fd018034493168ba67159b20d27570082b.tar.gz
libubus: process pending messages in data handler if stack depth is 0
Process pending messages before attempting to read new ones. After completing the poll, process any remaining pending messages. A previous message processing call which issued a request from within its handler may have left behind more object messages to process. Signed-off-by: Felix Fietkau <nbd@nbd.name> (cherry picked from commit ef038488edc35f4f671c09276cc3fb4ef706ae34)
-rw-r--r--libubus-io.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libubus-io.c b/libubus-io.c
index 3561ac4..a1fb62b 100644
--- a/libubus-io.c
+++ b/libubus-io.c
@@ -314,12 +314,20 @@ void __hidden ubus_handle_data(struct uloop_fd *u, unsigned int events)
struct ubus_context *ctx = container_of(u, struct ubus_context, sock);
int recv_fd = -1;
- while (get_next_msg(ctx, &recv_fd)) {
+ while (1) {
+ if (!ctx->stack_depth)
+ ctx->pending_timer.cb(&ctx->pending_timer);
+
+ if (!get_next_msg(ctx, &recv_fd))
+ break;
ubus_process_msg(ctx, &ctx->msgbuf, recv_fd);
if (uloop_cancelling() || ctx->cancel_poll)
break;
}
+ if (!ctx->stack_depth)
+ ctx->pending_timer.cb(&ctx->pending_timer);
+
if (u->eof)
ctx->connection_lost(ctx);
}