fix: eventsub stopped flag join (#6136)
This commit is contained in:
@@ -63,6 +63,7 @@
|
|||||||
- Dev: Refactored `Notebook`-related enums into their own file. (#6220)
|
- Dev: Refactored `Notebook`-related enums into their own file. (#6220)
|
||||||
- Dev: Refactored `SettingWidget::dropdown` for string enums to the source file. (#6293)
|
- Dev: Refactored `SettingWidget::dropdown` for string enums to the source file. (#6293)
|
||||||
- Dev: Don't try to save emote popup bounds if we're quitting. (#6292)
|
- Dev: Don't try to save emote popup bounds if we're quitting. (#6292)
|
||||||
|
- Dev: Only carefully join EventSub controller thread. (#6136)
|
||||||
- Dev: Remove `ChannelPageView::addCheckbox`. (#6305)
|
- Dev: Remove `ChannelPageView::addCheckbox`. (#6305)
|
||||||
- Dev: Remove `ChannelPageView::addIntInput`. (#6306)
|
- Dev: Remove `ChannelPageView::addIntInput`. (#6306)
|
||||||
- Dev: Implemented customizable display names for enums. (#6238)
|
- Dev: Implemented customizable display names for enums. (#6238)
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ const auto &LOG = chatterinoTwitchEventSub;
|
|||||||
|
|
||||||
namespace chatterino::eventsub {
|
namespace chatterino::eventsub {
|
||||||
|
|
||||||
|
using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
class QLogProxy : public lib::Logger
|
class QLogProxy : public lib::Logger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -79,6 +81,11 @@ Controller::Controller()
|
|||||||
std::tie(this->eventSubHost, this->eventSubPort, this->eventSubPath) =
|
std::tie(this->eventSubHost, this->eventSubPort, this->eventSubPath) =
|
||||||
getEventSubHost();
|
getEventSubHost();
|
||||||
this->thread = std::make_unique<std::thread>([this] {
|
this->thread = std::make_unique<std::thread>([this] {
|
||||||
|
// make sure we set in any case, even exceptions
|
||||||
|
auto guard = qScopeGuard([&] {
|
||||||
|
this->stoppedFlag.set();
|
||||||
|
});
|
||||||
|
|
||||||
this->ioContext.run();
|
this->ioContext.run();
|
||||||
});
|
});
|
||||||
renameThread(*this->thread, "C2EventSub");
|
renameThread(*this->thread, "C2EventSub");
|
||||||
@@ -111,16 +118,20 @@ Controller::~Controller()
|
|||||||
|
|
||||||
this->work.reset();
|
this->work.reset();
|
||||||
|
|
||||||
if (this->thread->joinable())
|
if (!this->thread->joinable())
|
||||||
{
|
{
|
||||||
this->thread->join();
|
qCInfo(LOG) << "Controller dtor end (not joinable)";
|
||||||
}
|
return;
|
||||||
else
|
|
||||||
{
|
|
||||||
qCWarning(LOG) << "Thread not joinable";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qCInfo(LOG) << "Controller dtor end";
|
if (this->stoppedFlag.waitFor(250ms))
|
||||||
|
{
|
||||||
|
this->thread->join();
|
||||||
|
qCInfo(LOG) << "Controller dtor end (joined)";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCWarning(LOG) << "Controller dtor end (stopped flag didn't stop)";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::removeRef(const SubscriptionRequest &request)
|
void Controller::removeRef(const SubscriptionRequest &request)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "twitch-eventsub-ws/logger.hpp"
|
#include "twitch-eventsub-ws/logger.hpp"
|
||||||
#include "twitch-eventsub-ws/session.hpp"
|
#include "twitch-eventsub-ws/session.hpp"
|
||||||
#include "util/ExponentialBackoff.hpp"
|
#include "util/ExponentialBackoff.hpp"
|
||||||
|
#include "util/OnceFlag.hpp"
|
||||||
#include "util/ThreadGuard.hpp"
|
#include "util/ThreadGuard.hpp"
|
||||||
|
|
||||||
#include <boost/asio/executor_work_guard.hpp>
|
#include <boost/asio/executor_work_guard.hpp>
|
||||||
@@ -149,6 +150,7 @@ private:
|
|||||||
std::unordered_map<SubscriptionRequest, Subscription> subscriptions;
|
std::unordered_map<SubscriptionRequest, Subscription> subscriptions;
|
||||||
|
|
||||||
std::atomic<bool> quitting = false;
|
std::atomic<bool> quitting = false;
|
||||||
|
OnceFlag stoppedFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DummyController : public IController
|
class DummyController : public IController
|
||||||
|
|||||||
Reference in New Issue
Block a user