summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-08-18 16:45:53 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-08-18 16:45:53 +0200
commit64275e09a21aa78076c1aaefc015e96c2864847b (patch)
tree321dffe5e388ebe86ab92be7f48fa6d7028532d3 /src/main.c
parentd1778a5beb18331b9e521527a66218fa468c9005 (diff)
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.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c21
1 files changed, 21 insertions, 0 deletions
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)
{