]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
WIP: this code certainly was suspicious lua-looping
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 31 May 2019 13:54:11 +0000 (15:54 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 31 May 2019 13:54:11 +0000 (15:54 +0200)
Small numbers would most likely get truncated to 0 when converted to
an integer, leading to 0ms lua timer.

daemon/lua/sandbox.lua.in

index b2b26c4312b755438b9ffc72c0645472bbe996ce..9f4d0ae558c30f22fcd66b68c651ad669216d6a3 100644 (file)
@@ -484,10 +484,10 @@ if has_cqueues then
                        -- Reschedule timeout or create new one
                        local timeout = self.cq:timeout()
                        if timeout then
-                               -- Throttle timeouts to avoid too frequent wakeups
-                               if timeout == 0 then timeout = 0.00001 end
-                               -- Convert from seconds to duration
+                               -- Convert from seconds to duration (milliseconds)
                                timeout = timeout * sec
+                               -- Don't allow 0ms timeout.
+                               if timeout < 1 then timeout = 1 end
                                if not self.next_timeout then
                                        self.next_timeout = event.after(timeout, self.on_step)
                                else