From 250db5605f33334692ae7e9376bfe3dd5d5d4141 Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Wed, 15 May 2024 18:09:07 -0700 Subject: [PATCH] Fix busy wait when tick == 0 (#1206) --- files/usr/local/bin/manager.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/files/usr/local/bin/manager.lua b/files/usr/local/bin/manager.lua index 05ab9606..9a64914a 100755 --- a/files/usr/local/bin/manager.lua +++ b/files/usr/local/bin/manager.lua @@ -51,15 +51,19 @@ if nixio.sysinfo().totalram < 32 * 1024 * 1024 then end function wait_for_ticks(ticks) - local when = nixio.sysinfo().uptime + ticks - while true - do - if ticks >= 0 then - coroutine.yield(ticks) - else - break + if ticks <= 0 then + coroutine.yield(0) + else + local when = nixio.sysinfo().uptime + ticks + while true + do + if ticks > 0 then + coroutine.yield(ticks) + else + break + end + ticks = when - nixio.sysinfo().uptime end - ticks = when - nixio.sysinfo().uptime end end