From 82e90a206c1e24147b7073e948fc63c4f232ecdc Mon Sep 17 00:00:00 2001 From: Leshana Date: Wed, 7 Jun 2017 16:42:06 -0400 Subject: [PATCH] Ports "Better repeated MC crash handling" * From https://github.com/tgstation/tgstation/pull/25813 * If the MC crashes: The problem subsystem will be rebooted on its 2nd strike and disabled on its third. --- code/controllers/master.dm | 19 +++++++++++++++++++ code/controllers/subsystem.dm | 2 ++ 2 files changed, 21 insertions(+) diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 360b739bad..fbf97f730c 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -107,7 +107,26 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING else msg += "\t [varname] = [varval]\n" log_world(msg) + + var/datum/controller/subsystem/BadBoy = Master.last_type_processed + var/FireHim = FALSE + if(istype(BadBoy)) + msg = null + switch(++BadBoy.failure_strikes) + if(2) + msg = "The [BadBoy.name] subsystem was the last to fire for 2 controller restarts. It will be recovered now and disabled if it happens again." + FireHim = TRUE + if(3) + msg = "The [BadBoy.name] subsystem seems to be destabilizing the MC and will be offlined." + BadBoy.flags |= SS_NO_FIRE + if(msg) + log_game(msg) + message_admins("[msg]") + log_world(msg) + if (istype(Master.subsystems)) + if(FireHim) + Master.subsystems += new BadBoy.type //NEW_SS_GLOBAL will remove the old one subsystems = Master.subsystems StartProcessing(10) else diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm index ff81fdc23e..b3e27a0175 100644 --- a/code/controllers/subsystem.dm +++ b/code/controllers/subsystem.dm @@ -27,6 +27,8 @@ var/datum/controller/subsystem/queue_next var/datum/controller/subsystem/queue_prev + var/static/failure_strikes = 0 //How many times we suspect this subsystem has crashed the MC, 3 strikes and you're out! + //Do not override /datum/controller/subsystem/New() return