]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daf: fix consensus() function to correctly detect empty answers
authorPetr Špaček <petr.spacek@nic.cz>
Tue, 31 Mar 2020 12:33:00 +0000 (14:33 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 2 Apr 2020 11:57:31 +0000 (13:57 +0200)
consensus() function is affected by
https://gitlab.labs.nic.cz/knot/knot-resolver/issues/554
so this fix helps only with single-instance scenarios.

modules/daf/daf.lua

index 9b6696eeb5964107aa985977533784e6561f7e80..94d0a49d06f8ea11b8b08673d5b403c0c8f5ab19 100644 (file)
@@ -214,9 +214,13 @@ function M.enable(id)
 end
 
 local function consensus(op, ...)
-       local ret = true
+       local ret = false
        local results = map(string.format(op, ...))
-       for _, r in ipairs(results) do
+       for idx, r in ipairs(results) do
+               if idx == 1 then
+                       -- non-empty table, init to true
+                       ret = true
+               end
                ret = ret and r
        end
        return ret