changeset 27011:f82f3dc29f9b

Don't try to process BOSH packet if there's no data (avoid a purple_strcasestr assertion). Also print friendlier error messages.
author Paul Aurich <paul@darkrain42.org>
date Thu, 21 May 2009 21:09:17 +0000
parents fdd2952d8639
children a667ba192449
files libpurple/protocols/jabber/bosh.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/bosh.c	Thu May 21 20:18:10 2009 +0000
+++ b/libpurple/protocols/jabber/bosh.c	Thu May 21 21:09:17 2009 +0000
@@ -301,7 +301,7 @@
 		return;
 	}
 
-	packet = g_string_new("");
+	packet = g_string_new(NULL);
 
 	g_string_printf(packet, "<body "
 	                "rid='%" G_GUINT64_FORMAT "' "
@@ -488,7 +488,7 @@
 }
 
 static void jabber_bosh_connection_boot(PurpleBOSHConnection *conn) {
-	GString *buf = g_string_new("");
+	GString *buf = g_string_new(NULL);
 
 	g_string_printf(buf, "<body content='text/xml; charset=utf-8' "
 	                "secure='true' "
@@ -686,7 +686,7 @@
 	int cnt, count = 0;
 
 	if (!conn->buf)
-		conn->buf = g_string_new("");
+		conn->buf = g_string_new(NULL);
 
 	/* Read once to prime cnt before the loop */
 	if (conn->psc)
@@ -705,7 +705,8 @@
 
 	if (cnt == 0 || (cnt < 0 && errno != EAGAIN)) {
 		if (cnt < 0)
-			purple_debug_info("jabber", "bosh read=%d, errno=%d\n", cnt, errno);
+			purple_debug_info("jabber", "bosh read=%d, errno=%d, error=%s\n",
+			                  cnt, errno, g_strerror(errno));
 		else
 			purple_debug_info("jabber", "bosh server closed the connection\n");
 
@@ -718,8 +719,8 @@
 		/* Process what we do have */
 	}
 
-
-	jabber_bosh_http_connection_process(conn);
+	if (conn->buf->len > 0)
+		jabber_bosh_http_connection_process(conn);
 }
 
 static void