From patchwork Tue Aug 17 12:00:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: adrian.frances@netduma.com X-Patchwork-Id: 1517709 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: 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=fo+4N0FF; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netduma-com.20150623.gappssmtp.com header.i=@netduma-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=l3XABruH; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GpqT9571Zz9sSn for ; Tue, 17 Aug 2021 22:04:29 +1000 (AEST) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=A5ay7Yf7UrxsprNmP0m3kp6/fl3zf65nFq8/7014Oy8=; b=fo+4N0FFVthFrI NNSdN1aunWqQicJ+aubW6Ywg0OgqylcZ7/si1ukEQ4BAY9ghVZ/oH0qh9GPC4sbhczHoeLhOpJ6rO qtgRGkmJEOfB5dx6TW1Jp7B+JeXEdEdV+EdVLTscwP2gmKpVOcCU4KloQujm9vlpWHJnYfwSGBnrb CntxQO97rOcz/sk7oMVwcl2m+JdY26F8jxlxlajk8s+s4o+BOmPyHq8i+RCAVhdEIH1n5L14NQ1v/ a/sG7Zk5PSdFIaF212Bd8aa/mPc8B0Oz1ZqlJ2pjXsOx9NEl9mitUqXvS5G2IlwqlTTAvp/G8HTOn oVMhS00E7i6DwYvnTplA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFxmd-002Lfp-V2; Tue, 17 Aug 2021 12:01:32 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFxma-002LeL-BW for openwrt-devel@lists.openwrt.org; Tue, 17 Aug 2021 12:01:29 +0000 Received: by mail-wr1-x42a.google.com with SMTP id r6so28261759wrt.4 for ; Tue, 17 Aug 2021 05:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netduma-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NnAcluDntAHu3rgVYzmbUtQQLFtwYOKxDMaE909urHM=; b=l3XABruHE4BXihiF0ma/alUYHqDs5PinL/1+GtEYy3843mygPqU3tuNlyzJcwwGESm hkXV4au9Rw8KM9aLsdQhbaMDCPFBUj2kyEaunNUBNq4Y/gLmVWW58j1uXACwbBYZRGh9 JtPubmUdDL0BG+1nhghgtECY+RY8SijY7athLAdXu6As0tzExBWGub/1CVqesvd/eZ4t gD1PmgkZavDbUDQ+3E3zV9mB9G41FCxJDHKgRrw7V0nVN0COUtoyYvdQT3xf3qX2Y/WR G2OtaLQX5j7+srG5BpxhsB9WNRGs92Cx36+5x/FeQcQIu1Dbs0lxkrg2mSUKfNZMWNGY MiYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NnAcluDntAHu3rgVYzmbUtQQLFtwYOKxDMaE909urHM=; b=j5pnl+oyyhbE8lp2dCzzS8l0zr79wm+nxkPkIFQP4Ns0HXtpB+QTrWBJljSnrqlf5+ WrIhckKCeDmV89EjKXAXI3TQI0lyTy22GIlwPlw+O7pz7NQOUBTnR2VxQ2q81qOzHN20 otnzAwV2hukRFAAF8dPjkeyZ1bIb6UvzFr3Zp2Q61kzh37JTVHpCBi/XQckHmqLc6B97 tcJyk8k++hgrOcyGHeqSwI3HXFDI2G42exhqK2Xie8cuZgFZljlggDKGujnrswf/nwXf YRgBbnBeSYDD8oEG8w2KNLc7yhfIV/F5DLq62RHLVmp/KeGakZ6jgzVL+wlVRTKXG6VC jVqg== X-Gm-Message-State: AOAM53220U70fNazsKui/lECWlXdjwor6E5XjXczGRaN5ddQ/F126lNn H8uxkwrAuD9YAoIIWqeOg+aztGiD5uMLR2KW X-Google-Smtp-Source: ABdhPJwOWc+wcYeNB88+jFOMa/hc6Se/VuFV6giTioI4RMyYHrebzT3P9vmXmblt3GdpPZmQxNX+DA== X-Received: by 2002:adf:b350:: with SMTP id k16mr3645492wrd.37.1629201685777; Tue, 17 Aug 2021 05:01:25 -0700 (PDT) Received: from lin-dev-002.ipa.internal.netduma.com ([77.95.36.54]) by smtp.gmail.com with ESMTPSA id n10sm1641541wms.3.2021.08.17.05.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 05:01:25 -0700 (PDT) From: adrian.frances@netduma.com To: openwrt-devel@lists.openwrt.org Cc: Adrian Frances Subject: [PATCH] ubus/lua: add support for custom timeout parameter on call Date: Tue, 17 Aug 2021 13:00:39 +0100 Message-Id: <20210817120039.8480-1-adrian.frances@netduma.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210817_050128_536556_33D205FC X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.7 (/) 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: Adrian Frances Allows for setting different timeouts per call, using the general timeout for the ubus connection as the fallback. Signed-off-by: Adrian Frances --- lua/ubus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Content analysis details: (0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:42a listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Adrian Frances Allows for setting different timeouts per call, using the general timeout for the ubus connection as the fallback. Signed-off-by: Adrian Frances --- lua/ubus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/ubus.c b/lua/ubus.c index e2bb081..fb75827 100644 --- a/lua/ubus.c +++ b/lua/ubus.c @@ -667,6 +667,7 @@ ubus_lua_call(lua_State *L) struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME); const char *path = luaL_checkstring(L, 2); const char *func = luaL_checkstring(L, 3); + int timeout = luaL_optint(L, 5, c->timeout); luaL_checktype(L, 4, LUA_TTABLE); blob_buf_init(&c->buf, 0); @@ -688,7 +689,7 @@ ubus_lua_call(lua_State *L) } top = lua_gettop(L); - rv = ubus_invoke(c->ctx, id, func, c->buf.head, ubus_lua_call_cb, L, c->timeout * 1000); + rv = ubus_invoke(c->ctx, id, func, c->buf.head, ubus_lua_call_cb, L, timeout * 1000); if (rv != UBUS_STATUS_OK) {