From 5c2da36ecd6bbd59727809f4cf730345b63a86f0 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 1 May 2021 18:47:45 +0200 Subject: [PATCH] Use a shorter delay for the first watchdog check --- src/wine-host/utils.cpp | 12 ++++++++---- src/wine-host/utils.h | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/wine-host/utils.cpp b/src/wine-host/utils.cpp index c002acb6..659aa8d3 100644 --- a/src/wine-host/utils.cpp +++ b/src/wine-host/utils.cpp @@ -80,7 +80,10 @@ MainContext::MainContext() events_timer(context), watchdog_context(), watchdog_timer(watchdog_context) { - async_handle_watchdog(); + // To account for hosts terminating before the bridged plugin has + // initialized, we'll do the first watchdog check five seconds. After this + // we'll run the timer on a 30 second interval. + async_handle_watchdog_timer(5s); watchdog_handler = Win32Thread([&]() { set_realtime_priority(false); @@ -142,10 +145,11 @@ MainContext::WatchdogGuard MainContext::register_watchdog(HostBridge& bridge) { return WatchdogGuard(bridge, watched_bridges, watched_bridges_mutex); } -void MainContext::async_handle_watchdog() { +void MainContext::async_handle_watchdog_timer( + std::chrono::steady_clock::duration interval) { // Try to keep a steady framerate, but add in delays to let other events // get handled if the GUI message handling somehow takes very long. - watchdog_timer.expires_at(std::chrono::steady_clock::now() + 20s); + watchdog_timer.expires_at(std::chrono::steady_clock::now() + interval); watchdog_timer.async_wait([&](const boost::system::error_code& error) { if (error.failed()) { return; @@ -160,6 +164,6 @@ void MainContext::async_handle_watchdog() { bridge->shutdown_if_dangling(); } - async_handle_watchdog(); + async_handle_watchdog_timer(30s); }); } diff --git a/src/wine-host/utils.h b/src/wine-host/utils.h index fa7ab504..29836930 100644 --- a/src/wine-host/utils.h +++ b/src/wine-host/utils.h @@ -325,7 +325,8 @@ class MainContext { * it's impossible to tell that the remote isn't alive anymore, and where * `recv()` will just hang indefinitely. We use this watchdog to avoid this. */ - void async_handle_watchdog(); + void async_handle_watchdog_timer( + std::chrono::steady_clock::duration interval); /** * The timer used to periodically handle X11 events and Win32 messages.