pidgin: 50243dd3: jabber: Be friendlier to servers when we...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Wed Jan 12 09:35:58 EST 2011
----------------------------------------------------------------------
Revision: 50243dd37132d4ae636e94f587bf6a41617ccd0d
Parent: 538b851ae7c6466621d0c3caa2e13a8a9097cf02
Author: darkrain42 at pidgin.im
Date: 01/12/11 09:31:52
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/50243dd37132d4ae636e94f587bf6a41617ccd0d
Changelog:
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.
Changes against parent 538b851ae7c6466621d0c3caa2e13a8a9097cf02
patched libpurple/protocols/jabber/bosh.c
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/bosh.c a748bd8ba14dc895052aae71ab42e4800895980c
+++ libpurple/protocols/jabber/bosh.c 6469985de38e66ac8b45b5187d4d33e955f902dc
@@ -306,8 +306,19 @@ find_available_http_connection(PurpleBOS
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);
purple_debug_info("jabber", "bosh: Creating and connecting new httpconn "
@@ -674,6 +685,7 @@ static void http_connection_disconnected
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 @@ static void http_connection_disconnected
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 @@ static void http_connection_disconnected
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,
More information about the Commits
mailing list