From d6529434ff33542dc2d73a9cc2b9fd7682871ca7 Mon Sep 17 00:00:00 2001 From: Charlie Nolan Date: Sun, 29 Sep 2024 03:54:31 -0700 Subject: [PATCH] Prevent sleeps in key handling from blocking SSinput (#26761) * Prevent sleeps in Move from blocking SSinput * Switch to watifor = FALSE * Move SHOULD_NOT_SLEEP * Whoops, that one's a redefine, too. --- code/controllers/subsystem/SSinput.dm | 2 ++ code/modules/input/input.dm | 2 ++ 2 files changed, 4 insertions(+) diff --git a/code/controllers/subsystem/SSinput.dm b/code/controllers/subsystem/SSinput.dm index 4e4e27477fc..0ee76429738 100644 --- a/code/controllers/subsystem/SSinput.dm +++ b/code/controllers/subsystem/SSinput.dm @@ -22,6 +22,8 @@ SUBSYSTEM_DEF(input) return "P: [length(processing)]" /datum/controller/subsystem/input/fire(resumed = FALSE) + // Sleeps in input handling are bad, because they can stall the entire subsystem indefinitely, breaking most movement. key_loop has SHOULD_NOT_SLEEP(TRUE), which helps, but it doesn't catch everything, so we also waitfor=FALSE here, as using INVOKE_ASYNC here is very unperformant. + set waitfor = FALSE var/list/to_cull for(var/client/C in processing) if(processing[C] + AUTO_CULL_TIME < world.time) diff --git a/code/modules/input/input.dm b/code/modules/input/input.dm index 4600c311fb8..36aafd6a61b 100644 --- a/code/modules/input/input.dm +++ b/code/modules/input/input.dm @@ -5,6 +5,8 @@ return /datum/proc/key_loop(client/C) + // Sleeps in input handling are bad, because they can stall the entire subsystem indefinitely, breaking most movement. The subsystem sets waitfor=FALSE, which works around this, but we'd rather avoid the sleeps in the first place. + SHOULD_NOT_SLEEP(TRUE) return /client/key_loop()