Reload luci.config for each thread
[project/luci.git] / libs / web / luasrc / config.lua
index 12d7e8c..53db82b 100644 (file)
@@ -26,13 +26,17 @@ limitations under the License.
 ]]--
 
 local util = require "luci.util"
-
-local pcall = pcall
-local require = require
-
-
-module "luci.config"
-
-pcall(function()
-       util.update(_M, require "luci.model.uci".cursor():get_all("luci"))
-end)
+module("luci.config",
+               function(m)
+                       if pcall(require, "luci.model.uci") then
+                               local config = util.threadlocal()
+                               setmetatable(m, {
+                                       __index = function(tbl, key)
+                                               if not config[key] then
+                                                       config[key] = luci.model.uci.cursor():get_all("luci", key)
+                                               end
+                                               return config[key]
+                                       end
+                               })
+                       end
+               end)