diff libpurple/protocols/jabber/bosh.c @ 27577:6d26258e9f1d

propagate from branch 'im.pidgin.pidgin' (head ac87c285c7056f86005dc157b9870745de471f74) to branch 'im.pidgin.cpw.darkrain42.roster' (head 976d874853ac9745edb77d3cf107b92ebc037c10)
author Paul Aurich <paul@darkrain42.org>
date Mon, 06 Jul 2009 04:37:41 +0000
parents 708f92703a13
children f541583e31bd
line wrap: on
line diff
--- a/libpurple/protocols/jabber/bosh.c	Wed Jun 10 04:42:11 2009 +0000
+++ b/libpurple/protocols/jabber/bosh.c	Mon Jul 06 04:37:41 2009 +0000
@@ -243,7 +243,7 @@
 	/* Easy solution: Does everyone involved support pipelining? Hooray! Just use
 	 * one TCP connection! */
 	if (conn->pipelining)
-		return conn->connections[0];
+		return conn->connections[0]->ready ? conn->connections[0] : NULL;
 
 	/* First loop, look for a connection that's ready */
 	for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) {
@@ -267,8 +267,8 @@
 }
 
 static void
-jabber_bosh_connection_send(PurpleBOSHConnection *conn, PurpleBOSHPacketType type,
-                            const char *data)
+jabber_bosh_connection_send(PurpleBOSHConnection *conn,
+                            PurpleBOSHPacketType type, const char *data)
 {
 	PurpleHTTPConnection *chosen;
 	GString *packet = NULL;
@@ -277,14 +277,16 @@
 
 	if (type != PACKET_NORMAL && !chosen) {
 		/*
-		 * For non-ordinary traffic, we don't want to 'buffer' it, so use the first
-		 * connection.
+		 * For non-ordinary traffic, we don't want to 'buffer' it, so use the
+		 * first connection.
 		 */
 		chosen = conn->connections[0];
 
-		if (!chosen->ready)
-			purple_debug_warning("jabber", "First BOSH connection wasn't ready. Bad "
-					"things may happen.\n");
+		if (!chosen->ready) {
+			purple_debug_info("jabber", "Unable to find a ready BOSH "
+					"connection. Ignoring send of type 0x%02x.\n", type);
+			return;
+		}
 	}
 
 	if (type == PACKET_NORMAL && (!chosen ||