pidgin: 99d06edb: Don't try to write when the BOSH connect...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Wed Jun 24 22:55:27 EDT 2009


-----------------------------------------------------------------
Revision: 99d06edb8217be8d94a7c9fc3f4d9c75835ff9d6
Ancestor: a7708017b7ddc9af35ba10166a927f3ecde4f1bc
Author: darkrain42 at pidgin.im
Date: 2009-06-25T02:53:26
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/99d06edb8217be8d94a7c9fc3f4d9c75835ff9d6

Modified files:
        libpurple/protocols/jabber/bosh.c

ChangeLog: 

Don't try to write when the BOSH connection isn't ready.

This was causing a Connection Refused to turn into a Write Error connection
error because jabber_close() calls jabber_bosh_connection_close().

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/bosh.c	e1cd497458b46c61b4254184eba01c6dd429d592
+++ libpurple/protocols/jabber/bosh.c	5b44ea1474a9c43e90167feedf9b376bbbb70e5f
@@ -243,7 +243,7 @@ find_available_http_connection(PurpleBOS
 	/* 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
 }
 
 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 @@ jabber_bosh_connection_send(PurpleBOSHCo
 
 	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 ||


More information about the Commits mailing list