# HG changeset patch # User Paul Aurich # Date 1237769266 0 # Node ID 79ca1cf55d9d45c82ca8679d9b8a39a6a873bec8 # Parent fcee93c74230d992997a4def7446c2d6b6b02454 Because BOSH works over connections that may die non-fatally, we need to limit the number of failed re-connection attempts before we declare the session lost. Reset the failures each time we process a full read from the server, which is a little hacky, but indicates that we have a *working* connection. diff -r fcee93c74230 -r 79ca1cf55d9d libpurple/protocols/jabber/bosh.c --- a/libpurple/protocols/jabber/bosh.c Mon Mar 23 00:38:20 2009 +0000 +++ b/libpurple/protocols/jabber/bosh.c Mon Mar 23 00:47:46 2009 +0000 @@ -30,6 +30,7 @@ #include "bosh.h" #define MAX_HTTP_CONNECTIONS 2 +#define MAX_FAILED_CONNECTIONS 3 typedef struct _PurpleHTTPConnection PurpleHTTPConnection; @@ -48,6 +49,7 @@ JabberStream *js; gboolean pipelining; PurpleHTTPConnection *connections[MAX_HTTP_CONNECTIONS]; + unsigned short failed_connections; gboolean ready; gboolean ssl; @@ -430,6 +432,10 @@ static void http_received_cb(const char *data, int len, PurpleBOSHConnection *conn) { + if (conn->failed_connections) + /* We've got some data, so reset the number of failed connections */ + conn->failed_connections = 0; + if (conn->receive_cb) { xmlnode *node = xmlnode_from_str(data, len); if (node) { @@ -602,8 +608,14 @@ /* Hmmmm, fall back to multiple connections */ conn->bosh->pipelining = FALSE; - /* No! Please! Take me back. It was me, not you! I was weak! */ - http_connection_connect(conn); + if (++conn->bosh->failed_connections == MAX_FAILED_CONNECTIONS) { + purple_connection_error_reason(conn->bosh->js->gc, + PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + _("Unable to establish a connection with the server")); + } else { + /* No! Please! Take me back. It was me, not you! I was weak! */ + http_connection_connect(conn); + } } void jabber_bosh_connection_connect(PurpleBOSHConnection *bosh) { @@ -711,6 +723,7 @@ /* Process what we do have */ } + jabber_bosh_http_connection_process(conn); }