Commit c0fd19fd authored by Ian Craggs's avatar Ian Craggs

Retry change didn't work on Windows

Bug: 442400
parent a4901bac
...@@ -1435,7 +1435,7 @@ int MQTTAsync_completeConnection(MQTTAsyncs* m, MQTTPacket* pack) ...@@ -1435,7 +1435,7 @@ int MQTTAsync_completeConnection(MQTTAsyncs* m, MQTTPacket* pack)
Messages* m = (Messages*)(outcurrent->content); Messages* m = (Messages*)(outcurrent->content);
m->lastTouch = 0; m->lastTouch = 0;
} }
MQTTProtocol_retry((time_t)0, 1); MQTTProtocol_retry((time_t)0, 1, 1);
if (m->c->connected != 1) if (m->c->connected != 1)
rc = MQTTASYNC_DISCONNECTED; rc = MQTTASYNC_DISCONNECTED;
} }
...@@ -2391,10 +2391,10 @@ void MQTTAsync_retry(void) ...@@ -2391,10 +2391,10 @@ void MQTTAsync_retry(void)
{ {
time(&(last)); time(&(last));
MQTTProtocol_keepalive(now); MQTTProtocol_keepalive(now);
MQTTProtocol_retry(now, 1); MQTTProtocol_retry(now, 1, 0);
} }
else else
MQTTProtocol_retry(now, 0); MQTTProtocol_retry(now, 0, 0);
FUNC_EXIT; FUNC_EXIT;
} }
......
...@@ -903,7 +903,7 @@ int MQTTClient_connectURIVersion(MQTTClient handle, MQTTClient_connectOptions* o ...@@ -903,7 +903,7 @@ int MQTTClient_connectURIVersion(MQTTClient handle, MQTTClient_connectOptions* o
Messages* m = (Messages*)(outcurrent->content); Messages* m = (Messages*)(outcurrent->content);
m->lastTouch = 0; m->lastTouch = 0;
} }
MQTTProtocol_retry((time_t)0, 1); MQTTProtocol_retry((time_t)0, 1, 1);
if (m->c->connected != 1) if (m->c->connected != 1)
rc = MQTTCLIENT_DISCONNECTED; rc = MQTTCLIENT_DISCONNECTED;
} }
...@@ -1518,10 +1518,10 @@ void MQTTClient_retry(void) ...@@ -1518,10 +1518,10 @@ void MQTTClient_retry(void)
{ {
time(&(last)); time(&(last));
MQTTProtocol_keepalive(now); MQTTProtocol_keepalive(now);
MQTTProtocol_retry(now, 1); MQTTProtocol_retry(now, 1, 0);
} }
else else
MQTTProtocol_retry(now, 0); MQTTProtocol_retry(now, 0, 0);
FUNC_EXIT; FUNC_EXIT;
} }
......
...@@ -549,14 +549,15 @@ void MQTTProtocol_keepalive(time_t now) ...@@ -549,14 +549,15 @@ void MQTTProtocol_keepalive(time_t now)
* MQTT retry processing per client * MQTT retry processing per client
* @param now current time * @param now current time
* @param client - the client to which to apply the retry processing * @param client - the client to which to apply the retry processing
* @param regardless boolean - retry packets regardless of retry interval (used on reconnect)
*/ */
void MQTTProtocol_retries(time_t now, Clients* client) void MQTTProtocol_retries(time_t now, Clients* client, int regardless)
{ {
ListElement* outcurrent = NULL; ListElement* outcurrent = NULL;
FUNC_ENTRY; FUNC_ENTRY;
if (now > (time_t)0 && client->retryInterval <= 0) /* 0 or -ive retryInterval turns off retry except on reconnect */ if (!regardless && client->retryInterval <= 0) /* 0 or -ive retryInterval turns off retry except on reconnect */
goto exit; goto exit;
while (client && ListNextElement(client->outboundMsgs, &outcurrent) && while (client && ListNextElement(client->outboundMsgs, &outcurrent) &&
...@@ -564,7 +565,7 @@ void MQTTProtocol_retries(time_t now, Clients* client) ...@@ -564,7 +565,7 @@ void MQTTProtocol_retries(time_t now, Clients* client)
Socket_noPendingWrites(client->net.socket)) /* there aren't any previous packets still stacked up on the socket */ Socket_noPendingWrites(client->net.socket)) /* there aren't any previous packets still stacked up on the socket */
{ {
Messages* m = (Messages*)(outcurrent->content); Messages* m = (Messages*)(outcurrent->content);
if (difftime(now, m->lastTouch) > max(client->retryInterval, 10)) if (regardless || difftime(now, m->lastTouch) > max(client->retryInterval, 10))
{ {
if (m->qos == 1 || (m->qos == 2 && m->nextMessageType == PUBREC)) if (m->qos == 1 || (m->qos == 2 && m->nextMessageType == PUBREC))
{ {
...@@ -618,8 +619,9 @@ exit: ...@@ -618,8 +619,9 @@ exit:
* MQTT retry protocol and socket pending writes processing. * MQTT retry protocol and socket pending writes processing.
* @param now current time * @param now current time
* @param doRetry boolean - retries as well as pending writes? * @param doRetry boolean - retries as well as pending writes?
* @param regardless boolean - retry packets regardless of retry interval (used on reconnect)
*/ */
void MQTTProtocol_retry(time_t now, int doRetry) void MQTTProtocol_retry(time_t now, int doRetry, int regardless)
{ {
ListElement* current = NULL; ListElement* current = NULL;
...@@ -640,7 +642,7 @@ void MQTTProtocol_retry(time_t now, int doRetry) ...@@ -640,7 +642,7 @@ void MQTTProtocol_retry(time_t now, int doRetry)
if (Socket_noPendingWrites(client->net.socket) == 0) if (Socket_noPendingWrites(client->net.socket) == 0)
continue; continue;
if (doRetry) if (doRetry)
MQTTProtocol_retries(now, client); MQTTProtocol_retries(now, client, regardless);
} }
FUNC_EXIT; FUNC_EXIT;
} }
......
...@@ -43,7 +43,7 @@ int MQTTProtocol_handlePubrels(void* pack, int sock); ...@@ -43,7 +43,7 @@ int MQTTProtocol_handlePubrels(void* pack, int sock);
int MQTTProtocol_handlePubcomps(void* pack, int sock); int MQTTProtocol_handlePubcomps(void* pack, int sock);
void MQTTProtocol_keepalive(time_t); void MQTTProtocol_keepalive(time_t);
void MQTTProtocol_retry(time_t, int); void MQTTProtocol_retry(time_t, int, int);
void MQTTProtocol_freeClient(Clients* client); void MQTTProtocol_freeClient(Clients* client);
void MQTTProtocol_emptyMessageList(List* msgList); void MQTTProtocol_emptyMessageList(List* msgList);
void MQTTProtocol_freeMessageList(List* msgList); void MQTTProtocol_freeMessageList(List* msgList);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment