Skip to content

Commit

Permalink
Fix for bug 472250, #29
Browse files Browse the repository at this point in the history
Bug: 472250
  • Loading branch information
Ian Craggs committed May 31, 2016
1 parent c251a20 commit 2405731
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/MQTTAsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Ian Craggs - fix for bug 444103 - success/failure callbacks not invoked
* Ian Craggs - fix for bug 484363 - segfault in getReadySocket
* Ian Craggs - automatic reconnect and offline buffering (send while disconnected)
* Ian Craggs - fix for bug 472250
*******************************************************************************/

/**
Expand Down Expand Up @@ -1322,8 +1323,13 @@ void MQTTAsync_checkTimeouts()
MQTTAsync_freeConnect(m->connect);
if (m->connect.onFailure)
{
MQTTAsync_failureData data;

data.token = 0;
data.code = MQTTASYNC_FAILURE;
data.message = "TCP connect timeout";
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
(*(m->connect.onFailure))(m->connect.context, NULL);
(*(m->connect.onFailure))(m->connect.context, &data);
}
MQTTAsync_startConnectRetry(m);
}
Expand Down Expand Up @@ -2739,8 +2745,13 @@ int MQTTAsync_connecting(MQTTAsyncs* m)
MQTTAsync_freeConnect(m->connect);
if (m->connect.onFailure)
{
MQTTAsync_failureData data;

data.token = 0;
data.code = MQTTASYNC_FAILURE;
data.message = "TCP/TLS connect failure";
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
(*(m->connect.onFailure))(m->connect.context, NULL);
(*(m->connect.onFailure))(m->connect.context, &data);
}
MQTTAsync_startConnectRetry(m);
}
Expand Down Expand Up @@ -2810,8 +2821,13 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
MQTTAsync_freeConnect(m->connect);
if (m->connect.onFailure)
{
MQTTAsync_failureData data;

data.token = 0;
data.code = MQTTASYNC_FAILURE;
data.message = "TCP connect completion failure";
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
(*(m->connect.onFailure))(m->connect.context, NULL);
(*(m->connect.onFailure))(m->connect.context, &data);
}
MQTTAsync_startConnectRetry(m);
}
Expand Down

0 comments on commit 2405731

Please sign in to comment.