From 609c0d46afee25dbf96b4875f5769d1efa5503db Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 9 Mar 2020 12:41:01 +0300 Subject: [PATCH] Implement stop watchdog Shows fatal error if stopping takes more than 5s. --- rpcs3/Emu/System.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 24d99fd14f..f6f303a2eb 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -1643,6 +1643,22 @@ void Emulator::Stop(bool restart) return; } + named_thread stop_watchdog("Stop Watchdog", [&]() + { + const auto start = std::chrono::steady_clock::now(); + + while (thread_ctrl::state() != thread_state::aborting) + { + if (std::chrono::steady_clock::now() - start >= 5s) + { + report_fatal_error("Stopping emulator took too long." + "\nSome thread has probably deadlocked. Aborting."); + } + + thread_ctrl::wait_for(100'000); + } + }); + const bool full_stop = !restart && !m_force_boot; const bool do_exit = full_stop && g_cfg.misc.autoexit;