# HG changeset patch # User Paul Aurich # Date 1294842740 0 # Node ID cc282e31e5c8fef67a076cba2a60c168ef5cbb70 # Parent 7986f4e5a05ffdddd3521a7ac72bc9e5b128ddfa# Parent 3b8e763fb1337654a4a1d0b2be32109597d02d87 merge of '50243dd37132d4ae636e94f587bf6a41617ccd0d' and 'e6af6508a94951bfea63caba1fc4f85932cea3a3' diff -r 3b8e763fb133 -r cc282e31e5c8 libpurple/protocols/jabber/bosh.c --- a/libpurple/protocols/jabber/bosh.c Tue Jan 11 05:24:33 2011 +0000 +++ b/libpurple/protocols/jabber/bosh.c Wed Jan 12 14:32:20 2011 +0000 @@ -306,7 +306,18 @@ return NULL; } - /* Third loop, look for one that's NULL and create a new connection */ + /* Third loop, is something offline that we can connect? */ + for (i = 0; i < NUM_HTTP_CONNECTIONS; ++i) { + if (conn->connections[i] && + conn->connections[i]->state == HTTP_CONN_OFFLINE) { + purple_debug_info("jabber", "bosh: Reconnecting httpconn " + "(%i, %p)\n", i, conn->connections[i]); + http_connection_connect(conn->connections[i]); + return NULL; + } + } + + /* Fourth loop, look for one that's NULL and create a new connection */ for (i = 0; i < NUM_HTTP_CONNECTIONS; ++i) { if (!conn->connections[i]) { conn->connections[i] = jabber_bosh_http_connection_init(conn); @@ -674,6 +685,7 @@ static void http_connection_disconnected(PurpleHTTPConnection *conn) { + gboolean had_requests = FALSE; /* * Well, then. Fine! I never liked you anyway, server! I was cheating on you * with AIM! @@ -697,7 +709,8 @@ conn->writeh = 0; } - if (conn->requests > 0 && conn->read_buf->len == 0) { + had_requests = (conn->requests > 0); + if (had_requests && conn->read_buf->len == 0) { purple_debug_error("jabber", "bosh: Adjusting BOSHconn requests (%d) to %d\n", conn->bosh->requests, conn->bosh->requests - conn->requests); conn->bosh->requests -= conn->requests; @@ -709,6 +722,12 @@ jabber_bosh_disable_pipelining(conn->bosh); } + if (!had_requests) + /* If the server disconnected us without any requests, let's + * just wait until we have something to send before we reconnect + */ + return; + if (++conn->bosh->failed_connections == MAX_FAILED_CONNECTIONS) { purple_connection_error_reason(conn->bosh->js->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,