Mercurial > pidgin.yaz
changeset 31592:7986f4e5a05f
jabber: Be friendlier to servers when we have nothing to say.
Don't try to reconnect immediately, but do so when we have something
to send. Untested (I'll test it later), but I'm hoping hsitas444 will
test it first. Refs #13008.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 12 Jan 2011 14:31:52 +0000 |
parents | 365ec0996ca0 |
children | cc282e31e5c8 |
files | libpurple/protocols/jabber/bosh.c |
diffstat | 1 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/bosh.c Mon Jan 10 05:20:06 2011 +0000 +++ b/libpurple/protocols/jabber/bosh.c Wed Jan 12 14:31:52 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,