diff --git a/ChangeLog.txt b/ChangeLog.txt index 3d86cc58..063e29a1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -28,6 +28,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. Build: - Fix cmake epoll detection. diff --git a/lib/loop.c b/lib/loop.c index bc2ba7f4..046dde0b 100644 --- a/lib/loop.c +++ b/lib/loop.c @@ -203,6 +203,13 @@ static int interruptible_sleep(struct mosquitto *mosq, time_t reconnect_delay) char pairbuf; int maxfd = 0; +#ifndef WIN32 + if(read(mosq->sockpairR, &pairbuf, 1) == 0){ + } +#else + recv(mosq->sockpairR, &pairbuf, 1, 0); +#endif + local_timeout.tv_sec = reconnect_delay; #ifdef HAVE_PSELECT local_timeout.tv_nsec = 0;