changeset 27194:aa2a2eae9c3e

Cleanup the code surrounding gc->disconnect_timeout and set it to 0 in the timer callback function to avoid trying to remove the timer after it's been triggered. The callback function returns FALSE to remove the timer.
author Mark Doliner <mark@kingant.net>
date Thu, 18 Jun 2009 19:36:46 +0000
parents 510f07e1f5c1
children c19d892f4381
files libpurple/connection.c
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/connection.c	Thu Jun 18 19:08:24 2009 +0000
+++ b/libpurple/connection.c	Thu Jun 18 19:36:46 2009 +0000
@@ -309,7 +309,7 @@
 	g_free(gc->password);
 	g_free(gc->display_name);
 
-	if (gc->disconnect_timeout)
+	if (gc->disconnect_timeout > 0)
 		purple_timeout_remove(gc->disconnect_timeout);
 
 	PURPLE_DBUS_UNREGISTER_POINTER(gc);
@@ -515,11 +515,20 @@
 static gboolean
 purple_connection_disconnect_cb(gpointer data)
 {
-	PurpleAccount *account = data;
-	char *password = g_strdup(purple_account_get_password(account));
+	PurpleAccount *account;
+	PurpleConnection *gc;
+	char *password;
+
+	account = data;
+	gc = purple_account_get_connection(account);
+
+	gc->disconnect_timeout = 0;
+
+	password = g_strdup(purple_account_get_password(account));
 	purple_account_disconnect(account);
 	purple_account_set_password(account, password);
 	g_free(password);
+
 	return FALSE;
 }
 
@@ -564,7 +573,7 @@
 	}
 
 	/* If we've already got one error, we don't need any more */
-	if (gc->disconnect_timeout)
+	if (gc->disconnect_timeout > 0)
 		return;
 
 	gc->wants_to_die = purple_connection_error_is_fatal (reason);