pidgin: 8e90f6ca: jabber: Ridiculously verbose logging for...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Aug 2 01:41:06 EDT 2009


-----------------------------------------------------------------
Revision: 8e90f6ca0ca33dc1253440e3e82ba40acb28d8b3
Ancestor: 1e866e4a2cdda6a142af03546517d09500ce7176
Author: darkrain42 at pidgin.im
Date: 2009-08-01T04:32:24
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8e90f6ca0ca33dc1253440e3e82ba40acb28d8b3

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

ChangeLog: 

jabber: Ridiculously verbose logging for BOSH.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/bosh.c	6c36dc9311eb247c7d60e5ae3298ff2601f9e440
+++ libpurple/protocols/jabber/bosh.c	cae5f50b0d37b82a54eb98004fe535a4f5283024
@@ -254,6 +254,19 @@ find_available_http_connection(PurpleBOS
 {
 	int i;
 
+	if (purple_debug_is_verbose()) {
+		for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) {
+			PurpleHTTPConnection *httpconn = conn->connections[i];
+			if (httpconn == NULL)
+				purple_debug_misc("jabber", "BOSH %p->connections[%d] = (nil)\n",
+				                  conn, i);
+			else
+				purple_debug_misc("jabber", "BOSH %p->connections[%d] = %p, state = %d"
+				                  ", requests = %d\n", conn, i, httpconn,
+				                  httpconn->state, httpconn->requests);
+		}
+	}
+
 	/* Easy solution: Does everyone involved support pipelining? Hooray! Just use
 	 * one TCP connection! */
 	if (conn->pipelining)
@@ -286,6 +299,8 @@ find_available_http_connection(PurpleBOS
 		}
 	}
 
+	purple_debug_warning("jabber", "Could not find a HTTP connection!\n");
+
 	/* None available. */
 	return NULL;
 }
@@ -299,7 +314,7 @@ jabber_bosh_connection_send(PurpleBOSHCo
 
 	chosen = find_available_http_connection(conn);
 
-	if (type != PACKET_NORMAL && !chosen) {
+	if ((type != PACKET_NORMAL) && !chosen) {
 		/*
 		 * For non-ordinary traffic, we can't 'buffer' it, so use the
 		 * first connection.
@@ -313,6 +328,14 @@ jabber_bosh_connection_send(PurpleBOSHCo
 		}
 	}
 
+	if (type == PACKET_NORMAL) {
+		if (conn->max_requests > 0 && conn->requests == conn->max_requests) {
+			purple_debug_warning("jabber", "BOSH connection %p has %d requests out\n", conn, conn->requests);
+		} else if (!chosen) {
+			purple_debug_warning("jabber", "No BOSH connection found!\n");
+		}
+	}
+
 	if (type == PACKET_NORMAL && (!chosen ||
 	        (conn->max_requests > 0 && conn->requests == conn->max_requests))) {
 		/*
@@ -325,6 +348,10 @@ jabber_bosh_connection_send(PurpleBOSHCo
 			purple_circ_buffer_append(conn->pending, data, len);
 		}
 
+		if (purple_debug_is_verbose())
+			purple_debug_misc("jabber", "bosh: %p has %" G_GSIZE_FORMAT " bytes in "
+			                  "the buffer.\n", conn, conn->pending->buflen);
+
 		return;
 	}
 
@@ -596,6 +623,10 @@ connection_common_established_cb(PurpleH
 {
 	/* Indicate we're ready and reset some variables */
 	conn->state = HTTP_CONN_CONNECTED;
+	if (conn->requests != 0)
+		purple_debug_error("jabber", "bosh: httpconn %p has %d requests, != 0\n",
+		                   conn, conn->requests);
+
 	conn->requests = 0;
 	if (conn->read_buf) {
 		g_string_free(conn->read_buf, TRUE);
@@ -651,6 +682,12 @@ static void http_connection_disconnected
 		conn->writeh = 0;
 	}
 
+	if (conn->requests > 0 && 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;
+		conn->requests = 0;
+	}
 	if (conn->bosh->pipelining)
 		/* Hmmmm, fall back to multiple connections */
 		conn->bosh->pipelining = FALSE;
@@ -951,6 +988,10 @@ http_connection_send_request(PurpleHTTPC
 	++conn->requests;
 	++conn->bosh->requests;
 
+	if (purple_debug_is_unsafe() && purple_debug_is_verbose())
+		/* Will contain passwords for SASL PLAIN and is verbose */
+		purple_debug_misc("jabber", "BOSH: Sending %s\n", data);
+
 	if (conn->writeh == 0)
 		ret = http_connection_do_send(conn, data, len);
 	else {


More information about the Commits mailing list