From: Marek Vavruša Date: Tue, 26 May 2015 22:51:14 +0000 (+0200) Subject: daemon/bindings: metatable wasn’t called on cache.{storage|size} X-Git-Tag: v1.0.0-beta1~125^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5272b4;p=thirdparty%2Fknot-resolver.git daemon/bindings: metatable wasn’t called on cache.{storage|size} the bindings wrote the keys on completion, so they existed and __newindex was never called - now current {storage|size} are saved as cache.current_{storage|size} --- diff --git a/daemon/bindings.c b/daemon/bindings.c index e2fb35cec..28a826b98 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -382,10 +382,10 @@ static int cache_open(lua_State *L) /* Store current configuration */ lua_getglobal(L, "cache"); - lua_pushstring(L, "size"); + lua_pushstring(L, "current_size"); lua_pushnumber(L, cache_size); lua_rawset(L, -3); - lua_pushstring(L, "storage"); + lua_pushstring(L, "current_storage"); lua_pushstring(L, uri); lua_rawset(L, -3); diff --git a/daemon/lua/sandbox.lua b/daemon/lua/sandbox.lua index 9a621f0c0..1e763bfcc 100644 --- a/daemon/lua/sandbox.lua +++ b/daemon/lua/sandbox.lua @@ -52,8 +52,8 @@ setmetatable(modules, { -- `cache.{size|storage} = value` setmetatable(cache, { __newindex = function (t,k,v) - if k == 'size' then t.open(v, rawget(t, 'storage')) - elseif k == 'storage' then t.open(rawget(t, 'size'), v) + if k == 'size' then t.open(v, rawget(t, 'current_storage')) + elseif k == 'storage' then t.open(rawget(t, 'current_size'), v) else rawset(t, k, v) end end })