im.pidgin.pidgin: 20f657930ee91380e681714a2194ae9ae515078c

khc at pidgin.im khc at pidgin.im
Sat Nov 3 17:00:40 EDT 2007


-----------------------------------------------------------------
Revision: 20f657930ee91380e681714a2194ae9ae515078c
Ancestor: db0689a4f6edbe8ef311f16047b3203ed94d24f8
Author: khc at pidgin.im
Date: 2007-11-03T20:55:15
Branch: im.pidgin.pidgin

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

ChangeLog: 

read as much from the fd as possible if we get a read event, hopefully will
fix a problem for people on OS X


-------------- next part --------------
============================================================
--- libpurple/protocols/msn/soap2.c	d5974c3b37ceebf702f233a619913a7c925ce706
+++ libpurple/protocols/msn/soap2.c	72bc1e36610319a84e1df4f101aa8b7d40ccc6fe
@@ -161,7 +161,7 @@ msn_soap_connected_cb(gpointer data, Pur
 	conn->connected = TRUE;
 
 	if (conn->event_handle == 0)
-		conn->event_handle = g_idle_add(msn_soap_connection_run, conn);
+		conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, conn);
 }
 
 static void
@@ -260,36 +260,46 @@ msn_soap_read_cb(gpointer data, gint fd,
 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond)
 {
     MsnSoapConnection *conn = data;
-	int count;
+	int count = 0, cnt;
 	char buf[8192];
 	char *linebreak;
 	char *cursor;
 	gboolean handled = FALSE;
 
-	g_return_if_fail(cond == PURPLE_INPUT_READ);
+	if (conn->message == NULL) {
+		conn->message = msn_soap_message_new(NULL, NULL);
+	}
 
-	count = purple_ssl_read(conn->ssl, buf, sizeof(buf));
-	purple_debug_info("soap", "read %d bytes\n", count);
-	if (count < 0 && errno == EAGAIN)
-		return;
-	else if (count <= 0) {
-		purple_debug_info("soap", "read: %s\n", g_strerror(errno));
+	while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) {
+		purple_debug_info("soap", "read %d bytes\n", cnt);
+		count += cnt;
+		if (conn->buf == NULL) {
+			conn->buf = g_string_new_len(buf, cnt);
+		} else {
+			g_string_append_len(conn->buf, buf, cnt);
+		}
+	}
+
+	if (cnt < 0) {
+		if (errno != EAGAIN) {
+			purple_debug_info("soap", "read: %s\n", g_strerror(errno));
+			purple_ssl_close(conn->ssl);
+			conn->ssl = NULL;
+			msn_soap_connection_handle_next(conn);
+			return;
+		} else if (count == 0) {
+			return;
+		}
+	}
+
+	if (cnt == 0 && count == 0) {
+		purple_debug_info("soap", "msn_soap_read_cb() called, but no data available?\n");
 		purple_ssl_close(conn->ssl);
 		conn->ssl = NULL;
 		msn_soap_connection_handle_next(conn);
 		return;
 	}
 
-	if (conn->message == NULL) {
-		conn->message = msn_soap_message_new(NULL, NULL);
-	}
-
-	if (conn->buf == NULL) {
-		conn->buf = g_string_new_len(buf, count);
-	} else {
-		g_string_append_len(conn->buf, buf, count);
-	}
-
 	purple_debug_info("soap", "current %s\n", conn->buf->str);
 
 	cursor = conn->buf->str + conn->handled_len;


More information about the Commits mailing list