pidgin: 2c953d94: Use separate variables to keep track of ...

markdoliner at pidgin.im markdoliner at pidgin.im
Mon Nov 24 21:45:27 EST 2008


-----------------------------------------------------------------
Revision: 2c953d945e8ab39ad778ed7ce41748dea0109113
Ancestor: e0aabff44a8895e6df143a6e57061eaa421c9f5e
Author: markdoliner at pidgin.im
Date: 2008-11-25T02:43:56
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2c953d945e8ab39ad778ed7ce41748dea0109113

Modified files:
        libpurple/protocols/msn/soap.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/soap.c	2672ed6a745ab404fb5d9eb2ceaec00e0a8f732f
+++ libpurple/protocols/msn/soap.c	a585590b4a5a3ae0079690892eab9ca8d83d9064
@@ -56,6 +56,7 @@ typedef struct _MsnSoapConnection {
 	gboolean connected;
 
 	guint event_handle;
+	guint run_timer;
 	GString *buf;
 	gsize handled_len;
 	gsize body_len;
@@ -109,6 +110,11 @@ msn_soap_connection_sanitize(MsnSoapConn
 		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_handle_next(MsnSoapC
 {
 	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 @@ msn_soap_message_send_internal(MsnSessio
 		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 @@ msn_soap_connected_cb(gpointer data, Pur
 
 	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 @@ msn_soap_connection_run(gpointer data)
 	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_run(gpointer data)
 				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);


More information about the Commits mailing list