Skip to content

Commit

Permalink
Fix timeout of send thread in Async client for v5
Browse files Browse the repository at this point in the history
When the outgoing packets fails to be sent due to hitting the limitation of the inflight maximum, it will wait on send_cond/send_sem. Send thread should be woken up on PUBACK message received. So it does not need to wait until timeout (1 second).

Signed-off-by: Tiejun Zhou <[email protected]>
  • Loading branch information
TiejunMS committed Mar 5, 2024
1 parent 6b1e202 commit 11757bf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/MQTTAsyncUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3078,7 +3078,15 @@ static MQTTPacket* MQTTAsync_cycle(SOCKET* sock, unsigned long timeout, int* rc)
else if (msgtype == PUBREC)
*rc = MQTTProtocol_handlePubrecs(pack, *sock, &pubToRemove);
else if (msgtype == PUBACK)
{
*rc = MQTTProtocol_handlePubacks(pack, *sock, &pubToRemove);
if (sendThread_state != STOPPED)
#if !defined(_WIN32) && !defined(_WIN64)
Thread_signal_cond(send_cond);
#else
Thread_post_sem(send_sem);
#endif
}
if (!m)
Log(LOG_ERROR, -1, "PUBCOMP, PUBACK or PUBREC received for no client, msgid %d", msgid);
if (m && (msgtype != PUBREC || ackrc >= MQTTREASONCODE_UNSPECIFIED_ERROR))
Expand Down

0 comments on commit 11757bf

Please sign in to comment.