From: Petr Špaček Date: Thu, 16 Aug 2018 14:50:18 +0000 (+0200) Subject: cache.clear: allow callback to modify return value X-Git-Tag: v3.0.0~1^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38cb1c675b5a2951dce56b3336b142404b560535;p=thirdparty%2Fknot-resolver.git cache.clear: allow callback to modify return value This is handy mainly for tests but it costs nothing so why not to do it. --- diff --git a/daemon/lua/sandbox.lua b/daemon/lua/sandbox.lua index 732d1d50d..9912eee11 100644 --- a/daemon/lua/sandbox.lua +++ b/daemon/lua/sandbox.lua @@ -216,14 +216,15 @@ cache.clear = function (name, exact_name, rr_type, chunk_size, callback) if callback == nil then callback = function (cberrors, cbname, cbexact_name, cbrr_type, cbchunk_size, cbself) if errors.count < 0 then error(ffi.string(ffi.C.knot_strerror(errors.count))) end - if (errors.count ~= cbchunk_size) then return end - event.after(1, function () - cache.clear(cbname, cbexact_name, cbrr_type, cbchunk_size, cbself) - end) + if (errors.count == cbchunk_size) then + event.after(1, function () + cache.clear(cbname, cbexact_name, cbrr_type, cbchunk_size, cbself) + end) + end + return cberrors end end - callback(errors, name, exact_name, rr_type, chunk_size, callback) - return errors + return callback(errors, name, exact_name, rr_type, chunk_size, callback) end -- Syntactic sugar for cache -- `cache[x] -> cache.get(x)`