From 44f0dda5fc9a5bb1664fdf830a6bad6ee0c4fd84 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Wed, 19 Aug 2015 16:52:01 +0200 Subject: [PATCH] change offline handling while I'm 4/5 offline this is a marvelous time to test this THINK POSITIVE! --- ot-recorder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ot-recorder.c b/ot-recorder.c index 3e2c580..dd0e560 100644 --- a/ot-recorder.c +++ b/ot-recorder.c @@ -602,7 +602,6 @@ void on_disconnect(struct mosquitto *mosq, void *userdata, int reason) //SQL sqlite3_finalize(ud->raw); //SQL sqlite3_finalize(ud->lastloc); //SQL sqlite3_close(ud->db); - run = FALSE; } } @@ -767,7 +766,12 @@ int main(int argc, char **argv) } while (run) { - mosquitto_loop_forever(mosq, -1, 1); + rc = mosquitto_loop(mosq, 0, 1); + if (run && rc) { + fprintf(stderr, "loop sleep: rc=%d [%s]\n", rc, mosquitto_strerror(rc)); + sleep(10); + mosquitto_reconnect(mosq); + } } mosquitto_disconnect(mosq);