pidgin: adf65a0a: Patch from tomgr and Maiku that workarou...

khc at pidgin.im khc at pidgin.im
Sun Jun 8 18:55:44 EDT 2008


-----------------------------------------------------------------
Revision: adf65a0a97c9fc089e408fff1b80abe063adcf2f
Ancestor: 72d77bee8c7f8271071848c21432141e960014a5
Author: khc at pidgin.im
Date: 2008-06-08T22:52:01
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/adf65a0a97c9fc089e408fff1b80abe063adcf2f

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

ChangeLog: 

Patch from tomgr and Maiku that workarounds some OS X issue,
References #5212

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/soap2.c	8e0e148ba9fb3cb30eef0df8f3a5cb380a9a4660
+++ libpurple/protocols/msn/soap2.c	7693e39a1b8668f9e40e2a2e8c40d1221b14b42a
@@ -82,6 +82,7 @@ static void msn_soap_connection_sanitize
 
 static void msn_soap_request_destroy(MsnSoapRequest *req);
 static void msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect);
+static void msn_soap_process(MsnSoapConnection *conn);
 
 static gboolean
 msn_soap_cleanup_each(gpointer key, gpointer value, gpointer data)
@@ -264,45 +265,53 @@ msn_soap_read_cb(gpointer data, gint fd,
 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond)
 {
 	MsnSoapConnection *conn = data;
-	int count = 0, cnt;
-	char buf[8192];
-	char *linebreak;
-	char *cursor;
-	gboolean handled = FALSE;
+	int count = 0, cnt, perrno;
+	/* This buffer needs to be larger than any packets received from
+		login.live.com or Adium will fail to receive the packet
+		(something weird with the login.live.com server). With NSS it works
+		fine, so I believe it's some bug with OS X */ 
+	char buf[16 * 1024];
 
 	if (conn->message == NULL) {
 		conn->message = msn_soap_message_new(NULL, NULL);
 	}
 
+	if (conn->buf == NULL) {
+		conn->buf = g_string_new_len(buf, 0);
+	}
+	
 	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);
-		}
+		g_string_append_len(conn->buf, buf, cnt);
 	}
 
-	if (cnt < 0) {
-		if (errno != EAGAIN) {
-			purple_debug_info("soap", "read: %s\n", g_strerror(errno));
+	/* && count is necessary for Adium, on OS X the last read always
+	   return an error, so we want to proceed anyway. See #5212 for
+	   discussion on this and the above buffer size issues */
+	if(cnt < 0 && errno == EAGAIN && count == 0)
+		return;
+
+	// msn_soap_process could alter errno
+	perrno = errno;
+	msn_soap_process(conn);
+	
+	if (cnt < 0 && perrno != EAGAIN) {
+		purple_debug_info("soap", "read: %s\n", g_strerror(perrno));
+		// It's possible msn_soap_process closed the ssl connection
+		if (conn->ssl) {
 			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;
-	}
+static void
+msn_soap_process(MsnSoapConnection *conn) {
+	gboolean handled = FALSE;
+	char *cursor;
+	char *linebreak;
 
 	purple_debug_info("soap", "current %s\n", conn->buf->str);
 


More information about the Commits mailing list