changeset 24532:d70eb6304eae

Use separate variables to keep track of the timer and the watcher. I believe only one of these will be used at any given time, and so while there is no overlap in their usage we need to use different variables so that we can call either purple_input_remove or purple_timeout_remove depending on the usage. I don't think this matters with glib because purple_input_remove and purple_timeout_remove both call g_source_remove, but it could be an issue when using other event loops. There's also the problem in line 673 where we add the watcher, but then if the call to msn_soap_write_cb fails we add a timer using the same variable. That's still going to be a little buggy.
author Mark Doliner <mark@kingant.net>
date Tue, 25 Nov 2008 02:43:56 +0000
parents faff4870f99d
children daefbf001774
files libpurple/protocols/msn/soap.c
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/soap.c	Tue Nov 25 02:18:00 2008 +0000
+++ b/libpurple/protocols/msn/soap.c	Tue Nov 25 02:43:56 2008 +0000
@@ -56,6 +56,7 @@
 	gboolean connected;
 
 	guint event_handle;
+	guint run_timer;
 	GString *buf;
 	gsize handled_len;
 	gsize body_len;
@@ -109,6 +110,11 @@
 		conn->event_handle = 0;
 	}
 
+	if (conn->run_timer) {
+		purple_timeout_remove(conn->run_timer);
+		conn->run_timer = 0;
+	}
+
 	if (conn->message) {
 		msn_soap_message_destroy(conn->message);
 		conn->message = NULL;
@@ -224,7 +230,7 @@
 {
 	msn_soap_connection_sanitize(conn, FALSE);
 
-	conn->event_handle = purple_timeout_add(0, msn_soap_connection_run,	conn);
+	conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn);
 
 	if (conn->current_request) {
 		MsnSoapRequest *req = conn->current_request;
@@ -253,8 +259,8 @@
 		g_queue_push_tail(conn->queue, req);
 	}
 
-	if (conn->event_handle == 0)
-		conn->event_handle = purple_timeout_add(0, msn_soap_connection_run,
+	if (conn->run_timer == 0)
+		conn->run_timer = purple_timeout_add(0, msn_soap_connection_run,
 			conn);
 }
 
@@ -595,8 +601,8 @@
 
 	conn->connected = TRUE;
 
-	if (conn->event_handle == 0)
-		conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, conn);
+	if (conn->run_timer == 0)
+		conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn);
 }
 
 MsnSoapMessage *
@@ -616,7 +622,7 @@
 	MsnSoapConnection *conn = data;
 	MsnSoapRequest *req = g_queue_peek_head(conn->queue);
 
-	conn->event_handle = 0;
+	conn->run_timer = 0;
 
 	if (req) {
 		if (conn->ssl == NULL) {
@@ -673,7 +679,7 @@
 				msn_soap_connection_sanitize(conn, FALSE);
 
 				g_queue_push_head(conn->queue, req);
-				conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, conn);
+				conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn);
 			}
 
 			g_free(body);