From ba71528805f777871f52fc278858f56677307064 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Wed, 23 Aug 2017 15:09:16 +0200 Subject: Fixes connection test. Sending the test request made the connection test be considered valid. Woops. --- src/main.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index a4254bd..dcb8a66 100644 --- a/src/main.c +++ b/src/main.c @@ -169,25 +169,30 @@ static int event_handling_loop timeouts += 1; /* 1200 timeouts => 5min */ - if ((timeouts == 1200) && (JH_irc_test_connection(irc) != 0)) + if (timeouts >= 1200) { - JH_S_ERROR(stderr, "Timed out due to fail connection test."); + if (JH_irc_is_testing_connection(irc)) + { + JH_S_ERROR + ( + stderr, + "Timed out due to lack of response to connection test." + ); - JH_irc_finalize(irc); + JH_irc_finalize(irc); - return -1; - } - else if (timeouts >= 1500) - { - JH_S_ERROR - ( - stderr, - "Timed out due to lack of response to connection test." - ); + return -1; + } + else if (JH_irc_start_connection_test(irc) < 0) + { + JH_S_ERROR(stderr, "Timed out due to failed connection test."); + + JH_irc_finalize(irc); - JH_irc_finalize(irc); + return -1; + } - return -1; + timeouts = 0; } } else -- cgit v1.2.3-70-g09d2