Commit d7875238 authored by Ian Craggs's avatar Ian Craggs

Part of fix for bug 416747 - make sure assignMsgId checks for free slots correctly

parent e4c40f18
...@@ -66,11 +66,9 @@ int messageIDCompare(void* a, void* b) ...@@ -66,11 +66,9 @@ int messageIDCompare(void* a, void* b)
int MQTTProtocol_assignMsgId(Clients* client) int MQTTProtocol_assignMsgId(Clients* client)
{ {
FUNC_ENTRY; FUNC_ENTRY;
++(client->msgID); client->msgID = (client->msgID == MAX_MSG_ID) ? 1 : client->msgID + 1;
while (ListFindItem(client->outboundMsgs, &(client->msgID), messageIDCompare) != NULL) while (ListFindItem(client->outboundMsgs, &(client->msgID), messageIDCompare) != NULL)
++(client->msgID); client->msgID = (client->msgID == MAX_MSG_ID) ? 1 : client->msgID + 1;
if (client->msgID == MAX_MSG_ID + 1)
client->msgID = 1;
FUNC_EXIT_RC(client->msgID); FUNC_EXIT_RC(client->msgID);
return client->msgID; return client->msgID;
} }
......
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