From a224a8f217a0428e1ad85f9a92760af5f0a06258 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 13 Aug 2020 14:32:47 +0100 Subject: [PATCH] Don't busy loop with `mosquitto_pub -l` on a slow connection. --- ChangeLog.txt | 1 + client/pub_client.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index f67fc472..a762ff9e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,6 @@ Clients: - All clients exit with an error exit code on CONNACK failure. Closes #1778. +- Don't busy loop with `mosquitto_pub -l` on a slow connection. 1.6.11 - 2020-08-11 diff --git a/client/pub_client.c b/client/pub_client.c index 3b0078a8..b39c700a 100644 --- a/client/pub_client.c +++ b/client/pub_client.c @@ -235,6 +235,17 @@ int pub_stdin_line_loop(struct mosquitto *mosq) mosquitto_loop_start(mosq); stdin_finished = false; do{ + if(status == STATUS_CONNECTING){ +#ifdef WIN32 + Sleep(100); +#else + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 100000000; + nanosleep(&ts, NULL); +#endif + } + if(status == STATUS_CONNACK_RECVD){ pos = 0; read_len = line_buf_len;