mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fix data race in PubSub (#4771)
This commit is contained in:
parent
14731012ad
commit
4c942a2a42
2 changed files with 23 additions and 14 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Unversioned
|
## Unversioned
|
||||||
|
|
||||||
|
- Bugfix: Fixed a data race when disconnecting from Twitch PubSub. (#4771)
|
||||||
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
|
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
|
||||||
- Dev: Temporarily disable High DPI scaling on Qt6 builds on Windows. (#4767)
|
- Dev: Temporarily disable High DPI scaling on Qt6 builds on Windows. (#4767)
|
||||||
- Dev: Tests now run on Ubuntu 22.04 instead of 20.04 to loosen C++ restrictions in tests. (#4774)
|
- Dev: Tests now run on Ubuntu 22.04 instead of 20.04 to loosen C++ restrictions in tests. (#4774)
|
||||||
|
|
|
@ -45,9 +45,15 @@ void PubSubClient::stop()
|
||||||
void PubSubClient::close(const std::string &reason,
|
void PubSubClient::close(const std::string &reason,
|
||||||
websocketpp::close::status::value code)
|
websocketpp::close::status::value code)
|
||||||
{
|
{
|
||||||
|
boost::asio::post(
|
||||||
|
this->websocketClient_.get_io_service().get_executor(),
|
||||||
|
[this, reason, code] {
|
||||||
|
// We need to post this request to the io service executor
|
||||||
|
// to ensure the weak pointer used in get_con_from_hdl is used in a safe way
|
||||||
WebsocketErrorCode ec;
|
WebsocketErrorCode ec;
|
||||||
|
|
||||||
auto conn = this->websocketClient_.get_con_from_hdl(this->handle_, ec);
|
auto conn =
|
||||||
|
this->websocketClient_.get_con_from_hdl(this->handle_, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
qCDebug(chatterinoPubSub)
|
qCDebug(chatterinoPubSub)
|
||||||
|
@ -58,9 +64,11 @@ void PubSubClient::close(const std::string &reason,
|
||||||
conn->close(code, reason, ec);
|
conn->close(code, reason, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
qCDebug(chatterinoPubSub) << "Error closing:" << ec.message().c_str();
|
qCDebug(chatterinoPubSub)
|
||||||
|
<< "Error closing:" << ec.message().c_str();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PubSubClient::listen(PubSubListenMessage msg)
|
bool PubSubClient::listen(PubSubListenMessage msg)
|
||||||
|
|
Loading…
Reference in a new issue