luci-base: Add possiblity to set path and timeout of ubus connection 4373/head
authorWojciech Jowsa <wojciech.jowsa@gmail.com>
Wed, 19 Aug 2020 10:49:03 +0000 (12:49 +0200)
committerWojciech Jowsa <wojciech.jowsa@gmail.com>
Wed, 19 Aug 2020 11:00:49 +0000 (13:00 +0200)
It might happen (e.g. when downloading a large file with low speed
connection) that the ubus connection will time out.
The ubus_connect function allows to specify
ubus socket path and ubus connection timeout
so it should allowed to set these arguments from luci.

Signed-off-by: Wojciech Jowsa <wojciech.jowsa@gmail.com>
libs/luci-lib-base/luasrc/util.lua

index 38e00ad83bd2d9fdafed77d2eddf7d8bff931476..89757917ff65c22f9210d219f8b377426dfc78de 100644 (file)
@@ -663,9 +663,9 @@ local function ubus_return(...)
        return ...
 end
 
-function ubus(object, method, data)
+function ubus(object, method, data, path, timeout)
        if not _ubus_connection then
-               _ubus_connection = _ubus.connect()
+               _ubus_connection = _ubus.connect(path, timeout)
                assert(_ubus_connection, "Unable to establish ubus connection")
        end