From f9bc9979d93e2b729a0237bc95d18958cb642d87 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Thu, 22 Dec 2016 12:05:50 +0100 Subject: [PATCH] fix 100% CPU usage when http_port == 0 closes #176 --- recorder.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recorder.c b/recorder.c index 6e56e30..8d77a2b 100644 --- a/recorder.c +++ b/recorder.c @@ -1699,7 +1699,10 @@ int main(int argc, char **argv) while (run) { #ifdef WITH_MQTT if (ud->port != 0) { - loop_timeout = 0; +#if WITH_HTTP + if (ud->http_port != 0) +#endif /* WITH_HTTP */ + loop_timeout = 0; /* this belongs to above `if' */ rc = mosquitto_loop(mosq, loop_timeout, /* max-packets */ 1); if (run && rc) { olog(LOG_INFO, "MQTT connection: rc=%d [%s] (errno=%d; %s). Sleeping...", rc, mosquitto_strerror(rc), errno, strerror(errno));