[PATCH] ubus/lua: add support for custom timeout parameter on call

adrian.frances at netduma.com adrian.frances at netduma.com
Tue Aug 17 05:00:39 PDT 2021


From: Adrian Frances <adrian.frances at netduma.com>

Allows for setting different timeouts per call, using the
general timeout for the ubus connection as the fallback.

Signed-off-by: Adrian Frances <adrian.frances at netduma.com>
---
 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)
 	{
-- 
2.25.1




More information about the openwrt-devel mailing list