From 234554a060b8c01a06820bdae09800f43053a1a1 Mon Sep 17 00:00:00 2001 From: payonel Date: Wed, 1 Nov 2017 18:02:36 -0700 Subject: [PATCH] protect slow boots from timeouts --- .../opencomputers/loot/openos/lib/core/boot.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 775eca3f5..4244ef680 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 @@ -42,6 +42,11 @@ if gpu and screen then gpu.fill(1, 1, w, h, " ") end local y = 1 +local uptime = computer.uptime +-- we actually want to ref the original pullSignal here because /lib/event intercepts it later +-- because of that, we must re-pushSignal when we use this, else things break badly +local pull = computer.pullSignal +local last_sleep = uptime() local function status(msg) if gpu and screen then gpu.set(1, y, msg) @@ -52,6 +57,16 @@ local function status(msg) y = y + 1 end end + -- boot can be slow in some environments, protect from timeouts + if uptime() - last_sleep > 1 then + local signal = table.pack(pull(0)) + -- there might not be any signal + if signal.n > 0 then + -- push the signal back in queue for the system to use it + computer.pushSignal(table.unpack(signal, 1, signal.n)) + end + last_sleep = uptime() + end end status("Booting " .. _OSVERSION .. "...")