From 706e65cd1e0798b8cb2e27ea30176d93b2c5e8a0 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sun, 2 Mar 2025 17:22:31 +0100 Subject: [PATCH] reduce pubsub/liveupdates pubsub clients "wait for clean exit" time from 1s to 100ms (#6019) --- CHANGELOG.md | 1 + src/providers/liveupdates/BasicPubSubManager.hpp | 6 +++--- src/providers/twitch/PubSubManager.cpp | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20bc483c..15c002a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ - Dev: Updated `googletest` to 1.16.0. (#5942) - Dev: Fixed duplicate CMake configure in clean builds. (#5940) - Dev: BTTV emotes are now loaded as WEBP. (#5957) +- Dev: Reduced time we wait for PubSub connections to cleanly exit from 1s to 100ms. (#6019) - Dev: Added snapshot tests for EventSub. (#5965) ## 2.5.2 diff --git a/src/providers/liveupdates/BasicPubSubManager.hpp b/src/providers/liveupdates/BasicPubSubManager.hpp index e4c8f8f6..b8fbb48e 100644 --- a/src/providers/liveupdates/BasicPubSubManager.hpp +++ b/src/providers/liveupdates/BasicPubSubManager.hpp @@ -159,16 +159,16 @@ public: // There is a case where a new client was initiated but not added to the clients list. // We just don't join the thread & let the operating system nuke the thread if joining fails // within 1s. - if (this->stoppedFlag_.waitFor(std::chrono::seconds{1})) + if (this->stoppedFlag_.waitFor(std::chrono::milliseconds{100})) { this->mainThread_->join(); return; } qCWarning(chatterinoLiveupdates) - << "Thread didn't finish within 1 second, force-stop the client"; + << "Thread didn't finish within 100ms, force-stop the client"; this->websocketClient_.stop(); - if (this->stoppedFlag_.waitFor(std::chrono::milliseconds{100})) + if (this->stoppedFlag_.waitFor(std::chrono::milliseconds{20})) { this->mainThread_->join(); return; diff --git a/src/providers/twitch/PubSubManager.cpp b/src/providers/twitch/PubSubManager.cpp index 84395237..1df50b14 100644 --- a/src/providers/twitch/PubSubManager.cpp +++ b/src/providers/twitch/PubSubManager.cpp @@ -596,16 +596,16 @@ void PubSub::stop() // within 1s. // We could fix the underlying bug, but this is easier & we realistically won't use this exact code // for super much longer. - if (this->stoppedFlag_.waitFor(std::chrono::seconds{1})) + if (this->stoppedFlag_.waitFor(std::chrono::milliseconds{100})) { this->thread->join(); return; } qCWarning(chatterinoLiveupdates) - << "Thread didn't finish within 1 second, force-stop the client"; + << "Thread didn't finish within 100ms, force-stop the client"; this->websocketClient.stop(); - if (this->stoppedFlag_.waitFor(std::chrono::milliseconds{100})) + if (this->stoppedFlag_.waitFor(std::chrono::milliseconds{20})) { this->thread->join(); return;