From e9c18f834710e72a30b978694940fba1b8cca1bf Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 30 Sep 2014 00:42:30 +0100 Subject: [PATCH] mosquitto_loop_forever now quits after a fatal error, rather than blindly retrying. --- ChangeLog.txt | 4 ++++ lib/mosquitto.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index d9aef713..9ec9e07c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -47,6 +47,10 @@ Clients: - Both clients can now load default configuration options from a file. - Add -1 (oneshot) option to mosquitto_sub. +Client library: +- mosquitto_loop_forever now quits after a fatal error, rather than blindly + retrying. + 1.3.2 - 2014xxxx ================ diff --git a/lib/mosquitto.c b/lib/mosquitto.c index 8e5117e1..1cd5a9e6 100644 --- a/lib/mosquitto.c +++ b/lib/mosquitto.c @@ -937,6 +937,22 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets) reconnects = 0; } }while(run && rc == MOSQ_ERR_SUCCESS); + /* Quit after fatal errors. */ + switch(rc){ + case MOSQ_ERR_NOMEM: + case MOSQ_ERR_PROTOCOL: + case MOSQ_ERR_INVAL: + case MOSQ_ERR_NOT_FOUND: + case MOSQ_ERR_TLS: + case MOSQ_ERR_PAYLOAD_SIZE: + case MOSQ_ERR_NOT_SUPPORTED: + case MOSQ_ERR_AUTH: + case MOSQ_ERR_ACL_DENIED: + case MOSQ_ERR_UNKNOWN: + case MOSQ_ERR_ERRNO: + case MOSQ_ERR_EAI: + return rc; + } if(errno == EPROTO){ return rc; }