diff --git a/src/MQTTAsync.c b/src/MQTTAsync.c index 8f32bc87..5763465a 100644 --- a/src/MQTTAsync.c +++ b/src/MQTTAsync.c @@ -1260,7 +1260,12 @@ thread_return_type WINAPI MQTTAsync_sendThread(void* n) int rc; while (commands->count > 0) + { + int before = commands->count; MQTTAsync_processCommand(); + if (before == commands->count) + break; /* no commands were processed, so go into a wait */ + } #if !defined(WIN32) && !defined(WIN64) rc = Thread_wait_cond(send_cond, 1); if ((rc = Thread_wait_cond(send_cond, 1)) != 0 && rc != ETIMEDOUT)