diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-02-26 09:20:30 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-02-26 09:20:30 +0000 |
commit | b958cb50be77eb9084b1701750ad738a62fb04f0 (patch) | |
tree | 8f98608089ff94606f52ede6ec4ba70b5393cdd3 | |
parent | 441a67e2d5032f1f2f9babd027c5fc6bb5676952 (diff) |
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.
-rw-r--r-- | irc.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -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; } |