From 85fa8369f6d364399e2da526d16838764610a5be Mon Sep 17 00:00:00 2001 From: Martin Hecht Date: Wed, 11 Oct 2017 15:13:51 +0200 Subject: [PATCH] call run_tunnel from a single place --- src/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index 664a0324..dc43fac0 100644 --- a/src/main.c +++ b/src/main.c @@ -392,13 +392,15 @@ int main(int argc, char **argv) log_warn("This process was not spawned with root " "privileges, this will probably not work.\n"); - if (run_tunnel(&cfg) == 0) - ret = EXIT_SUCCESS; - while ((ret == EXIT_SUCCESS) && (cfg.loop!=0) && (get_sig_received()==0)) { - sleep(cfg.loop); - if (run_tunnel(&cfg) != 0) + do { + if (run_tunnel(&cfg) != 0) { ret = EXIT_FAILURE; - } + } else + ret = EXIT_SUCCESS; + if ((cfg.loop > 0) && (get_sig_received() == 0)) + sleep(cfg.loop); + } while ((get_sig_received() == 0) && (cfg.loop !=0)); + goto exit; user_error: