changeset 1588:2a3cac07e69d

[gaim-migrate @ 1598] More MSN fixes. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Fri, 16 Mar 2001 09:25:03 +0000
parents 69a004b5820a
children 963f761c5511
files plugins/msn/msn.c
diffstat 1 files changed, 36 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/msn/msn.c	Fri Mar 16 07:30:14 2001 +0000
+++ b/plugins/msn/msn.c	Fri Mar 16 09:25:03 2001 +0000
@@ -87,6 +87,29 @@
 unsigned long long globalc = 0;
 static void msn_callback(gpointer data, gint source, GdkInputCondition condition);
 
+void free_msn_conn(struct msn_conn *mc)
+{
+	if (mc->user)
+		free(mc->user);
+
+	if (mc->secret)
+		free(mc->secret);
+
+	if (mc->session)
+		free(mc->session);
+
+	if (mc->txqueue)
+		free(mc->txqueue);
+
+	gdk_input_remove(mc->inpa);
+	close(mc->fd);
+
+	msn_connections = g_slist_remove(msn_connections, mc);
+
+	g_free(mc);
+}
+
+
 struct msn_conn *find_msn_conn_by_user(gchar * user)
 {
 	struct msn_conn *mc;
@@ -200,10 +223,9 @@
 	bzero(buf, MSN_BUF_LEN);
 	do 
 	{
-		if (read(source, buf + i, 1) < 0)
+		if (!read(source, buf + i, 1))
 		{
-			hide_login_progress(gc, "Read error");
-			signoff(gc);
+			free_msn_conn(mc);
 			return;
 		}
 
@@ -262,10 +284,16 @@
 		
 	do 
 	{
-		if (read(source, buf + i, 1) < 0)
+		if (!read(source, buf + i, 1))
 		{
-			hide_login_progress(gc, "Read error");
-			signoff(gc);
+			if (md->fd == source)
+			{
+				hide_login_progress(gc, "Read error");
+				signoff(gc);
+			}
+
+			close(source);
+			
 			return;
 		}
 
@@ -516,7 +544,7 @@
 		
 	do 
 	{
-		if (read(source, buf + i, 1) < 0)
+		if (!read(source, buf + i, 1))
 		{
 			hide_login_progress(gc, "Read error");
 			signoff(gc);
@@ -568,25 +596,7 @@
 		if (mc)
 		{
 			/* Looks like we need to close up some stuff :-) */
-
-			if (mc->user)
-				free(mc->user);
-
-			if (mc->secret)
-				free(mc->secret);
-
-			if (mc->session)
-				free(mc->session);
-
-			if (mc->txqueue)
-				free(mc->txqueue);
-
-			gdk_input_remove(mc->inpa);
-			close(mc->fd);
-
-			msn_connections = g_slist_remove(msn_connections, mc);
-
-			g_free(mc);
+			free_msn_conn(mc);
 		}
 		
 		g_strfreev(res);