From 748bcdde269da5cd8184418f0df334e12338a541 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 21 Nov 2010 15:23:54 +0000 Subject: Time out if logging in takes too long (2m for now). Except for Twitter OAuth login, which requires user action. This mostly solves problems with OSCAR login silently failing, but may also be useful in other places. --- protocols/account.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'protocols/account.c') diff --git a/protocols/account.c b/protocols/account.c index 50b7be8e..819bdc10 100644 --- a/protocols/account.c +++ b/protocols/account.c @@ -338,6 +338,8 @@ void account_del( bee_t *bee, account_t *acc ) } } +static gboolean account_on_timeout( gpointer d, gint fd, b_input_condition cond ); + void account_on( bee_t *bee, account_t *a ) { if( a->ic ) @@ -350,6 +352,9 @@ void account_on( bee_t *bee, account_t *a ) a->reconnect = 0; a->prpl->login( a ); + + if( !( a->ic->flags & OPT_SLOW_LOGIN ) ) + a->ic->keepalive = b_timeout_add( 120000, account_on_timeout, a->ic ); } void account_off( bee_t *bee, account_t *a ) @@ -363,6 +368,16 @@ void account_off( bee_t *bee, account_t *a ) } } +static gboolean account_on_timeout( gpointer d, gint fd, b_input_condition cond ) +{ + struct im_connection *ic = d; + + imcb_error( ic, "Connection timeout" ); + imc_logout( ic, TRUE ); + + return FALSE; +} + struct account_reconnect_delay { int start; -- cgit v1.2.3