1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 18:28:52 -05:00

Fix bug in source detach model which resulted in deadlock.

This commit is contained in:
Gordon McCann 2023-04-02 09:26:34 -04:00
parent 88173a16cf
commit 7abe92582c
2 changed files with 9 additions and 2 deletions

View File

@ -100,9 +100,12 @@ namespace Specter {
SPEC_PROFILE_FUNCTION(); SPEC_PROFILE_FUNCTION();
SPEC_INFO("Detaching physics data source..."); SPEC_INFO("Detaching physics data source...");
std::scoped_lock<std::mutex> guard(m_sourceMutex);
m_activeFlag = false; m_activeFlag = false;
{
std::scoped_lock<std::mutex> guard(m_sourceMutex);
m_source.reset(nullptr); m_source.reset(nullptr);
}
if (m_physThread != nullptr && m_physThread->joinable()) if (m_physThread != nullptr && m_physThread->joinable())
{ {
m_physThread->join(); m_physThread->join();

View File

@ -61,14 +61,18 @@ namespace Specter {
void RitualClient::Disconnect() void RitualClient::Disconnect()
{ {
SPEC_INFO("Disconnecting...");
if (IsConnected()) if (IsConnected())
{ {
asio::post(m_context, [this]() { m_socket.close(); }); asio::post(m_context, [this]() { m_socket.close(); });
} }
SPEC_INFO("Disconnected...");
SPEC_INFO("Stopping...");
m_context.stop(); m_context.stop();
if (m_ioThread.joinable()) if (m_ioThread.joinable())
m_ioThread.join(); m_ioThread.join();
SPEC_INFO("Stopped...");
} }
void RitualClient::ReadSize() void RitualClient::ReadSize()