pidgin: c5d89bdf: Set the session error after disconnectin...

qulogic at pidgin.im qulogic at pidgin.im
Tue Jul 21 02:21:34 EDT 2009


-----------------------------------------------------------------
Revision: c5d89bdf85c78749bd9dd328ccf393db0f55d016
Ancestor: ad05ad0ab9adf12fcfef66c99fe6ac5368479cc1
Author: qulogic at pidgin.im
Date: 2009-07-21T03:56:44
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c5d89bdf85c78749bd9dd328ccf393db0f55d016

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

ChangeLog: 

Set the session error after disconnecting the servconn instead of before.
The disconnect callback may try to do something that would set another
error, thus hiding the original one.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/servconn.c	4aa4a14bc4b230628741b76dca44582c0dc3349c
+++ libpurple/protocols/msn/servconn.c	f7ccf3d4030c082edd6db91abcffdf9204dc48b7
@@ -125,13 +125,14 @@ msn_servconn_got_error(MsnServConn *serv
 void
 msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error)
 {
-	char *tmp;
+	MsnSession *session = servconn->session;
+	MsnServConnType type = servconn->type;
 	const char *reason;
 
 	const char *names[] = { "Notification", "Switchboard" };
 	const char *name;
 
-	name = names[servconn->type];
+	name = names[type];
 
 	switch (error)
 	{
@@ -147,24 +148,25 @@ msn_servconn_got_error(MsnServConn *serv
 
 	purple_debug_error("msn", "Connection error from %s server (%s): %s\n",
 					 name, servconn->host, reason);
-	tmp = g_strdup_printf(_("Connection error from %s server:\n%s"),
-						  name, reason);
 
-	if (servconn->type == MSN_SERVCONN_NS)
+	if (type == MSN_SERVCONN_SB)
 	{
-		msn_session_set_error(servconn->session, MSN_ERROR_SERVCONN, tmp);
-	}
-	else if (servconn->type == MSN_SERVCONN_SB)
-	{
 		MsnSwitchBoard *swboard;
 		swboard = servconn->cmdproc->data;
 		if (swboard != NULL)
 			swboard->error = MSN_SB_ERROR_CONNECTION;
 	}
 
+	/* servconn->disconnect_cb may destroy servconn, so don't use it again */
 	msn_servconn_disconnect(servconn);
 
-	g_free(tmp);
+	if (type == MSN_SERVCONN_NS)
+	{
+		char *tmp = g_strdup_printf(_("Connection error from %s server:\n%s"),
+		                            name, reason);
+		msn_session_set_error(session, MSN_ERROR_SERVCONN, tmp);
+		g_free(tmp);
+	}
 }
 
 /**************************************************************************


More information about the Commits mailing list