From f275e0d44ae9bac643c94f78c3a605b9426fcdea Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Wed, 28 Jun 2023 15:26:45 +0200 Subject: [PATCH] propose fix for #3628 --- changelog.md | 8 ++++++-- .../assets/opencomputers/loot/network/data/bin/ping.lua | 6 +++--- .../assets/opencomputers/loot/openos/boot/02_os.lua | 2 +- .../assets/opencomputers/loot/openos/lib/core/boot.lua | 2 +- src/main/resources/assets/opencomputers/lua/machine.lua | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 24fd723e0..404a6d10d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,11 @@ ## Fixes/improvements -* [#3635] ArrayIndexOutOfBoundsException when using servers with 3 network cards -* [#3634] Internet card selector update logic erroneously drops non-ready keys +* [#3635] Fix ArrayIndexOutOfBoundsException when using servers with 3 network cards +* [#3634] Fix Internet card selector update logic erroneously dropping non-ready keys + +## OpenOS fixes/improvements + +* [#3628] Fix jitter when using os.sleep() ## List of contributors diff --git a/src/main/resources/assets/opencomputers/loot/network/data/bin/ping.lua b/src/main/resources/assets/opencomputers/loot/network/data/bin/ping.lua index 6ba9fc731..2801a1311 100644 --- a/src/main/resources/assets/opencomputers/loot/network/data/bin/ping.lua +++ b/src/main/resources/assets/opencomputers/loot/network/data/bin/ping.lua @@ -51,7 +51,7 @@ local function doSleep() local deadline = computer.uptime() + (tonumber(options.i) or tonumber(options.interval) or 1) repeat event.pull(deadline - computer.uptime()) - until computer.uptime() >= deadline + until (computer.uptime() - deadline) >= -0.001 end local function doPing() @@ -66,9 +66,9 @@ local function doPing() local e, replier, id, inpayload repeat e, replier, id, inpayload = event.pull(deadline - computer.uptime(), "ping_reply") - until computer.uptime() >= deadline or (e == "ping_reply" and id == icmp_seq) + until ((computer.uptime() - deadline) >= -0.001) or (e == "ping_reply" and id == icmp_seq) - if computer.uptime() >= deadline and e ~= "ping_reply" then + if ((computer.uptime() - deadline) >= -0.001) and e ~= "ping_reply" then verbose(tostring(len).." bytes lost: icmp_seq="..tostring(icmp_seq)) elseif inpayload == payload then stats.received = stats.received + 1 diff --git a/src/main/resources/assets/opencomputers/loot/openos/boot/02_os.lua b/src/main/resources/assets/opencomputers/loot/openos/boot/02_os.lua index 314635696..d193f9480 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/boot/02_os.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/boot/02_os.lua @@ -27,7 +27,7 @@ function os.sleep(timeout) local deadline = computer.uptime() + (timeout or 0) repeat event.pull(deadline - computer.uptime()) - until computer.uptime() >= deadline + until (computer.uptime() - deadline) >= -0.001 end os.setenv("PATH", "/bin:/usr/bin:/home/bin:.") diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua index 2955da292..c18cc4c95 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua @@ -1,7 +1,7 @@ -- called from /init.lua local raw_loadfile = ... -_G._OSVERSION = "OpenOS 1.8.2" +_G._OSVERSION = "OpenOS 1.8.3" -- luacheck: globals component computer unicode _OSVERSION local component = component diff --git a/src/main/resources/assets/opencomputers/lua/machine.lua b/src/main/resources/assets/opencomputers/lua/machine.lua index df2cd8cf8..150863fd0 100644 --- a/src/main/resources/assets/opencomputers/lua/machine.lua +++ b/src/main/resources/assets/opencomputers/lua/machine.lua @@ -1405,7 +1405,7 @@ local libcomputer = { if signal.n > 0 then return table.unpack(signal, 1, signal.n) end - until computer.uptime() >= deadline + until (computer.uptime() - deadline) >= -0.001 end, beep = function(...)