]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/bindings: metatable wasn’t called on cache.{storage|size}
authorMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 26 May 2015 22:51:14 +0000 (00:51 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 26 May 2015 22:51:48 +0000 (00:51 +0200)
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}

daemon/bindings.c
daemon/lua/sandbox.lua

index e2fb35cec3db26126f68354eb194b5ce71191a7b..28a826b98121f42e9b7e30ee9d6e5c5100c7d859 100644 (file)
@@ -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);
 
index 9a621f0c0b4d87b28267996dbd9aec4cbd669de4..1e763bfcc844a8bd0f2266e5b11f8991f2a45763 100644 (file)
@@ -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
 })