From b958cb50be77eb9084b1701750ad738a62fb04f0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 26 Feb 2012 09:20:30 +0000 Subject: Changing ping behaviour. Pinging seems to be misbehaving for some people for reasons not entirely clear to me. Instead of suppressing a PING to the client if we're still waiting for a response to a previous one, just keep sending them. One PONG will be enough to stay connected but that's okay. --- irc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'irc.c') diff --git a/irc.c b/irc.c index ffcc6cb3..36be2c24 100644 --- a/irc.c +++ b/irc.c @@ -857,30 +857,30 @@ void irc_umode_set( irc_t *irc, const char *s, gboolean allow_priv ) connection when the user fails to connect in IRC_LOGIN_TIMEOUT secs. */ static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond ) { + double now = gettime(); irc_t *irc = _irc; - int rv = 0; + int fail = 0; if( !( irc->status & USTATUS_LOGGED_IN ) ) { - if( gettime() > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) ) - rv = gettime() - irc->last_pong; + if( now > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) ) + fail = now - irc->last_pong; } else { - if( ( gettime() > ( irc->last_pong + global.conf->ping_interval ) ) && !irc->pinging ) + if( now > ( irc->last_pong + global.conf->ping_timeout ) ) { - irc_write( irc, "PING :%s", IRC_PING_STRING ); - irc->pinging = 1; + fail = now - irc->last_pong; } - else if( gettime() > ( irc->last_pong + global.conf->ping_timeout ) ) + else { - rv = gettime() - irc->last_pong; + irc_write( irc, "PING :%s", IRC_PING_STRING ); } } - if( rv > 0 ) + if( fail > 0 ) { - irc_abort( irc, 0, "Ping Timeout: %d seconds", rv ); + irc_abort( irc, 0, "Ping Timeout: %d seconds", fail ); return FALSE; } -- cgit v1.2.3