From 280e655722c8660ec2dff9b08f82b10d5559bfd9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 6 Aug 2008 00:07:07 +0100 Subject: Simple exponential backoff code. Have to add a maximum delay setting, something like 5*5<300: 5s, multiply by 5 on each failure, but stop increasing once we hit 5m. --- protocols/nogaim.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 7466e93a..eb3fc2ad 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -266,6 +266,10 @@ void imcb_connected( struct im_connection *ic ) /* Also necessary when we're not away, at least for some of the protocols. */ imc_set_away( ic, u->away ); + + /* Apparently we're connected successfully, so reset the + exponential backoff timer. */ + ic->acc->auto_reconnect_delay = 0; } gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ) @@ -330,7 +334,7 @@ void imc_logout( struct im_connection *ic, int allow_reconnect ) else if( allow_reconnect && set_getbool( &irc->set, "auto_reconnect" ) && set_getbool( &a->set, "auto_reconnect" ) ) { - int delay = set_getint( &irc->set, "auto_reconnect_delay" ); + int delay = account_reconnect_delay( a ); imcb_log( ic, "Reconnecting in %d seconds..", delay ); a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); -- cgit v1.2.3