mirror of
https://github.com/eclipse/paho.mqtt.cpp.git
synced 2025-05-09 19:31:22 +08:00
Fix potential deadlock in set_callback
Signed-off-by: Sandro Scherer <sand.scherer@gmail.com>
This commit is contained in:
parent
6131a30530
commit
5956f3b112
@ -314,10 +314,11 @@ void async_client::remove_token(token* tok)
|
||||
// Callback management
|
||||
|
||||
void async_client::set_callback(callback& cb)
|
||||
{
|
||||
{
|
||||
guard g(lock_);
|
||||
userCallback_ = &cb;
|
||||
|
||||
}
|
||||
int rc = MQTTAsync_setConnected(cli_, this, &async_client::on_connected);
|
||||
|
||||
if (rc == MQTTASYNC_SUCCESS) {
|
||||
@ -330,6 +331,7 @@ void async_client::set_callback(callback& cb)
|
||||
MQTTAsync_setConnected(cli_, nullptr, nullptr);
|
||||
|
||||
if (rc != MQTTASYNC_SUCCESS) {
|
||||
guard g(lock_);
|
||||
userCallback_ = nullptr;
|
||||
throw exception(rc);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user