From 64275e09a21aa78076c1aaefc015e96c2864847b Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 18 Aug 2017 16:45:53 +0200 Subject: Attempts to deal with timeouts. libircclient does not seem to detect any issue when the connection has been dropped due to external causes. I added a test (getting the current channel topic)that should trigger if 5min go by without anything happening, hopefully this will cause libircclient to detect the connection problem, if not, implement a timeout from the lack of replies concerning the topic should not be too hard. --- src/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 2646809..becd6a3 100644 --- a/src/main.c +++ b/src/main.c @@ -106,6 +106,9 @@ static int event_handling_loop struct timeval tv; fd_set in_set, out_set; int fd_max, error; + int timeouts; + + timeouts = 0; for (;;) { @@ -161,6 +164,24 @@ static int event_handling_loop strerror(error) ); } + else if (error == 0) + { + timeouts += 1; + + /* 1200 timeouts => 5min */ + if ((timeouts >= 1200) && (JH_irc_test_connection(irc) != 0)) + { + JH_S_ERROR(stderr, "Timed out."); + + JH_irc_finalize(irc); + + return -1; + } + } + else + { + timeouts = 0; + } if (JH_irc_post_select(irc, &in_set, &out_set) < 0) { -- cgit v1.2.3-70-g09d2