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
|
||||
|
||||
- Bugfix: Fixed a data race when disconnecting from Twitch PubSub. (#4771)
|
||||
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
|
||||
- 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)
|
||||
|
|
|
@ -45,22 +45,30 @@ void PubSubClient::stop()
|
|||
void PubSubClient::close(const std::string &reason,
|
||||
websocketpp::close::status::value code)
|
||||
{
|
||||
WebsocketErrorCode ec;
|
||||
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;
|
||||
|
||||
auto conn = this->websocketClient_.get_con_from_hdl(this->handle_, ec);
|
||||
if (ec)
|
||||
{
|
||||
qCDebug(chatterinoPubSub)
|
||||
<< "Error getting con:" << ec.message().c_str();
|
||||
return;
|
||||
}
|
||||
auto conn =
|
||||
this->websocketClient_.get_con_from_hdl(this->handle_, ec);
|
||||
if (ec)
|
||||
{
|
||||
qCDebug(chatterinoPubSub)
|
||||
<< "Error getting con:" << ec.message().c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
conn->close(code, reason, ec);
|
||||
if (ec)
|
||||
{
|
||||
qCDebug(chatterinoPubSub) << "Error closing:" << ec.message().c_str();
|
||||
return;
|
||||
}
|
||||
conn->close(code, reason, ec);
|
||||
if (ec)
|
||||
{
|
||||
qCDebug(chatterinoPubSub)
|
||||
<< "Error closing:" << ec.message().c_str();
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool PubSubClient::listen(PubSubListenMessage msg)
|
||||
|
|
Loading…
Reference in a new issue