changeset 6003:0ca618645cec

[gaim-migrate @ 6451] this fixes a couple jabber segfaults, and hopefully doesn't break anything. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 03 Jul 2003 18:27:22 +0000
parents 6e3650c096b0
children 3b4f94adc7d4
files src/connection.c src/protocols/jabber/jabber.c
diffstat 2 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/connection.c	Thu Jul 03 14:24:49 2003 +0000
+++ b/src/connection.c	Thu Jul 03 18:27:22 2003 +0000
@@ -50,6 +50,8 @@
 	gaim_connection_set_account(gc, account);
 	gaim_account_set_connection(account, gc);
 
+	connections = g_list_append(connections, gc);
+
 	return gc;
 }
 
@@ -69,6 +71,8 @@
 	gaim_debug(GAIM_DEBUG_INFO, "connection",
 			   "Destroying connection %p\n", gc);
 
+	connections = g_list_remove(connections, gc);
+
 	account = gaim_connection_get_account(gc);
 	gaim_account_set_connection(account, NULL);
 
@@ -118,8 +122,6 @@
 
 	gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling serv_login\n");
 
-	connections = g_list_append(connections, gc);
-
 	serv_login(account);
 }
 
@@ -147,8 +149,6 @@
 
 		serv_close(gc);
 
-		connections = g_list_remove(connections, gc);
-
 		gaim_connection_set_state(gc, GAIM_DISCONNECTED);
 
 		gaim_event_broadcast(event_signoff, gc);
@@ -348,6 +348,12 @@
 		ops->notice(gc, text);
 }
 
+static gboolean disconnect_conn_cb(gpointer data)
+{
+	gaim_connection_disconnect(data);
+	return FALSE;
+}
+
 void
 gaim_connection_error(GaimConnection *gc, const char *text)
 {
@@ -361,7 +367,7 @@
 	if (ops != NULL && ops->disconnected != NULL)
 		ops->disconnected(gc, text);
 
-	gaim_connection_disconnect(gc);
+	g_timeout_add(0, disconnect_conn_cb, gc);
 }
 
 void
--- a/src/protocols/jabber/jabber.c	Thu Jul 03 14:24:49 2003 +0000
+++ b/src/protocols/jabber/jabber.c	Thu Jul 03 18:27:22 2003 +0000
@@ -139,7 +139,6 @@
 	gboolean did_import;
 	GSList *chats;
 	time_t idle;
-	gboolean die;
 	GHashTable *buddies;
 	GSList *file_transfers;
 };
@@ -675,8 +674,6 @@
 		gaim_debug(GAIM_DEBUG_MISC, "jabber",
 				   "input (len %d): %s\n", len, buf);
 		XML_Parse(gjc->parser, buf, len, 0);
-		if (jd->die)
-			gaim_connection_destroy(GJ_GC(gjc));
 	} else if (len < 0 || errno != EAGAIN) {
 		STATE_EVT(JCONN_STATE_OFF)
 	}
@@ -1938,8 +1935,6 @@
 		} else {
 			gaim_connection_error(GJ_GC(gjc), _("Unknown login error"));
 		}
-
-		jd->die = TRUE;
 	}
 }
 
@@ -4197,8 +4192,6 @@
 		} else {
 			gaim_connection_error(GJ_GC(gjc), _("Unknown registration error"));
 		}
-
-		jd->die = TRUE;
 	}
 }
 
@@ -4273,7 +4266,7 @@
  */
 void jabber_register_user(GaimAccount *account)
 {
-	GaimConnection *gc = gaim_account_get_connection(account);
+	GaimConnection *gc = gaim_connection_new(account);
 	struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1);
 	char *loginname = create_valid_jid(account->username, DEFAULT_SERVER, "Gaim");