From patchwork Wed Feb 16 10:43:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1593623 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=QLNqwVKG; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JzF7b14VBz9sFv for ; Wed, 16 Feb 2022 21:48:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lYnv8Q2m/xvwhJn9rbuOzyMvtGOb0/TUAxkUwqpcZQo=; b=QLNqwVKG7gtTil NovOxvaWC4sNMupSOZQHRUvRLohMTKWuQsswo7JCdxMdpQaIB1LVcPFCmQLgaVrzayM7R04GdpkyD kDMJXzOFC6hsOgD6/E9aKThQZX6Mlz/qnk/UWr5xmIkecmc9LvunP6PUz6RvbASO8mc+f/KeddoB/ lhfStl+rux5P6mwmGnwohUE2uGr/7sPtl62nLfyFtOanvd1jWr77X4j/7Ka/iGNWOM9+JoLfg9qha pg/M5fio2cgwJRRdd8cVkeVfGtYKEbgCWA/HLxa2EXQ6fJT5W2/MQiNMueE6PaIDMyxCX9ewTufKj HqV87nXP3hLLV4XZukQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKHmx-006bMG-RZ; Wed, 16 Feb 2022 10:44:00 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKHms-006bJf-6T for openwrt-devel@lists.openwrt.org; Wed, 16 Feb 2022 10:43:56 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 35F343D0A; Wed, 16 Feb 2022 11:43:49 +0100 (CET) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 1b981d1d; Wed, 16 Feb 2022 11:43:25 +0100 (CET) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Felix Fietkau Subject: [PATCH 19.07 ubus 2/3] libubus: process pending messages in data handler if stack depth is 0 Date: Wed, 16 Feb 2022 11:43:37 +0100 Message-Id: <20220216104338.15704-3-ynezz@true.cz> In-Reply-To: <20220216104338.15704-1-ynezz@true.cz> References: <20220216104338.15704-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220216_024354_469525_912A133D X-CRM114-Status: UNSURE ( 8.78 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Felix Fietkau 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. Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Felix Fietkau 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 (cherry picked from commit ef038488edc35f4f671c09276cc3fb4ef706ae34) --- libubus-io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libubus-io.c b/libubus-io.c index 3561ac462eb9..a1fb62b1162f 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); }