Skip to content

Commit

Permalink
Merge pull request #3 from Infineon/bugfix/gracefully-shutdown
Browse files Browse the repository at this point in the history
Only call disconnect when Client is connected to a broker
  • Loading branch information
glaure authored Apr 8, 2022
2 parents 04d97fb + 75ac993 commit 989027a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mqtt-plugin/src/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ void Service::disconnect()
std::lock_guard<std::mutex> lock(m_mtx);
if (m_client)
{
m_client->disconnect(100)->wait();
m_client->disable_callbacks();
m_client.reset();
if (m_client->is_connected())
{
m_client->disconnect(100)->wait();
m_client->disable_callbacks();
m_client.reset();
}
}
}

Expand Down

0 comments on commit 989027a

Please sign in to comment.