When an error is encountered when processing a packet, the client is supposed to reconnect but that doesn't always happen correctly because of two issues:
When a full packet is read (as opposed to completing a pending packet), the result from s_process_mqtt_packet was never checked, so the connection is not terminated as it should.
The pending packet stored in connection->thread_data.pending_packet was not cleaned-up on shutdown, so if there was a disconnection while a packet was still pending, after reconnecting the client would try to resume the pending packet. This would eventually cause ping timeouts and more connection attempts until the number of bytes corresponding to the pending packet is fully read.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description of changes:
When an error is encountered when processing a packet, the client is supposed to reconnect but that doesn't always happen correctly because of two issues:
s_process_mqtt_packet
was never checked, so the connection is not terminated as it should.connection->thread_data.pending_packet
was not cleaned-up on shutdown, so if there was a disconnection while a packet was still pending, after reconnecting the client would try to resume the pending packet. This would eventually cause ping timeouts and more connection attempts until the number of bytes corresponding to the pending packet is fully read.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.