From 8442926841c194e547cb529df26c2caa8c489eda Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 11 Mar 2021 21:02:30 +0000 Subject: [PATCH] Fix connections retrying very rapidly in some situations. Thanks to Abilio Marques. --- ChangeLog.txt | 1 + lib/loop.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9f760e59..12692ef9 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -18,6 +18,7 @@ Broker: Client library: - Fix encrypted connections incorrectly connecting when the CA file passed to `mosquitto_tls_set()` is empty or invalid. Closes #2130. +- Fix connections retrying very rapidly in some situations. Clients: - Fix possible loss of data in `mosquitto_pub -l` when sending multiple long diff --git a/lib/loop.c b/lib/loop.c index a3773b0a..6648def6 100644 --- a/lib/loop.c +++ b/lib/loop.c @@ -209,6 +209,15 @@ static int interruptible_sleep(struct mosquitto *mosq, unsigned long reconnect_d #else local_timeout.tv_usec = 0; #endif + +#ifndef WIN32 + if(read(mosq->sockpairR, &pairbuf, 1) == 0){ + } +#else + recv(mosq->sockpairR, &pairbuf, 1, 0); +#endif + + FD_ZERO(&readfds); maxfd = 0; if(mosq->sockpairR != INVALID_SOCKET){