Mercurial > pidgin
comparison libpurple/protocols/jabber/bosh.c @ 27789:1ff7de15d856
jabber: Ridiculously verbose logging for BOSH.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 01 Aug 2009 04:32:24 +0000 |
parents | 46e80810b095 |
children | 3eef8392a54b |
comparison
equal
deleted
inserted
replaced
27788:46e80810b095 | 27789:1ff7de15d856 |
---|---|
252 static PurpleHTTPConnection * | 252 static PurpleHTTPConnection * |
253 find_available_http_connection(PurpleBOSHConnection *conn) | 253 find_available_http_connection(PurpleBOSHConnection *conn) |
254 { | 254 { |
255 int i; | 255 int i; |
256 | 256 |
257 if (purple_debug_is_verbose()) { | |
258 for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) { | |
259 PurpleHTTPConnection *httpconn = conn->connections[i]; | |
260 if (httpconn == NULL) | |
261 purple_debug_misc("jabber", "BOSH %p->connections[%d] = (nil)\n", | |
262 conn, i); | |
263 else | |
264 purple_debug_misc("jabber", "BOSH %p->connections[%d] = %p, state = %d" | |
265 ", requests = %d\n", conn, i, httpconn, | |
266 httpconn->state, httpconn->requests); | |
267 } | |
268 } | |
269 | |
257 /* Easy solution: Does everyone involved support pipelining? Hooray! Just use | 270 /* Easy solution: Does everyone involved support pipelining? Hooray! Just use |
258 * one TCP connection! */ | 271 * one TCP connection! */ |
259 if (conn->pipelining) | 272 if (conn->pipelining) |
260 return conn->connections[0]->state == HTTP_CONN_CONNECTED ? | 273 return conn->connections[0]->state == HTTP_CONN_CONNECTED ? |
261 conn->connections[0] : NULL; | 274 conn->connections[0] : NULL; |
284 http_connection_connect(conn->connections[i]); | 297 http_connection_connect(conn->connections[i]); |
285 return NULL; | 298 return NULL; |
286 } | 299 } |
287 } | 300 } |
288 | 301 |
302 purple_debug_warning("jabber", "Could not find a HTTP connection!\n"); | |
303 | |
289 /* None available. */ | 304 /* None available. */ |
290 return NULL; | 305 return NULL; |
291 } | 306 } |
292 | 307 |
293 static void | 308 static void |
297 PurpleHTTPConnection *chosen; | 312 PurpleHTTPConnection *chosen; |
298 GString *packet = NULL; | 313 GString *packet = NULL; |
299 | 314 |
300 chosen = find_available_http_connection(conn); | 315 chosen = find_available_http_connection(conn); |
301 | 316 |
302 if (type != PACKET_NORMAL && !chosen) { | 317 if ((type != PACKET_NORMAL) && !chosen) { |
303 /* | 318 /* |
304 * For non-ordinary traffic, we can't 'buffer' it, so use the | 319 * For non-ordinary traffic, we can't 'buffer' it, so use the |
305 * first connection. | 320 * first connection. |
306 */ | 321 */ |
307 chosen = conn->connections[0]; | 322 chosen = conn->connections[0]; |
308 | 323 |
309 if (chosen->state != HTTP_CONN_CONNECTED) { | 324 if (chosen->state != HTTP_CONN_CONNECTED) { |
310 purple_debug_info("jabber", "Unable to find a ready BOSH " | 325 purple_debug_info("jabber", "Unable to find a ready BOSH " |
311 "connection. Ignoring send of type 0x%02x.\n", type); | 326 "connection. Ignoring send of type 0x%02x.\n", type); |
312 return; | 327 return; |
328 } | |
329 } | |
330 | |
331 if (type == PACKET_NORMAL) { | |
332 if (conn->max_requests > 0 && conn->requests == conn->max_requests) { | |
333 purple_debug_warning("jabber", "BOSH connection %p has %d requests out\n", conn, conn->requests); | |
334 } else if (!chosen) { | |
335 purple_debug_warning("jabber", "No BOSH connection found!\n"); | |
313 } | 336 } |
314 } | 337 } |
315 | 338 |
316 if (type == PACKET_NORMAL && (!chosen || | 339 if (type == PACKET_NORMAL && (!chosen || |
317 (conn->max_requests > 0 && conn->requests == conn->max_requests))) { | 340 (conn->max_requests > 0 && conn->requests == conn->max_requests))) { |
322 */ | 345 */ |
323 if (data) { | 346 if (data) { |
324 int len = data ? strlen(data) : 0; | 347 int len = data ? strlen(data) : 0; |
325 purple_circ_buffer_append(conn->pending, data, len); | 348 purple_circ_buffer_append(conn->pending, data, len); |
326 } | 349 } |
350 | |
351 if (purple_debug_is_verbose()) | |
352 purple_debug_misc("jabber", "bosh: %p has %" G_GSIZE_FORMAT " bytes in " | |
353 "the buffer.\n", conn, conn->pending->buflen); | |
327 | 354 |
328 return; | 355 return; |
329 } | 356 } |
330 | 357 |
331 packet = g_string_new(NULL); | 358 packet = g_string_new(NULL); |
594 static void | 621 static void |
595 connection_common_established_cb(PurpleHTTPConnection *conn) | 622 connection_common_established_cb(PurpleHTTPConnection *conn) |
596 { | 623 { |
597 /* Indicate we're ready and reset some variables */ | 624 /* Indicate we're ready and reset some variables */ |
598 conn->state = HTTP_CONN_CONNECTED; | 625 conn->state = HTTP_CONN_CONNECTED; |
626 if (conn->requests != 0) | |
627 purple_debug_error("jabber", "bosh: httpconn %p has %d requests, != 0\n", | |
628 conn, conn->requests); | |
629 | |
599 conn->requests = 0; | 630 conn->requests = 0; |
600 if (conn->read_buf) { | 631 if (conn->read_buf) { |
601 g_string_free(conn->read_buf, TRUE); | 632 g_string_free(conn->read_buf, TRUE); |
602 conn->read_buf = NULL; | 633 conn->read_buf = NULL; |
603 } | 634 } |
649 if (conn->writeh) { | 680 if (conn->writeh) { |
650 purple_input_remove(conn->writeh); | 681 purple_input_remove(conn->writeh); |
651 conn->writeh = 0; | 682 conn->writeh = 0; |
652 } | 683 } |
653 | 684 |
685 if (conn->requests > 0 && conn->read_buf->len == 0) { | |
686 purple_debug_error("jabber", "bosh: Adjusting BOSHconn requests (%d) to %d\n", | |
687 conn->bosh->requests, conn->bosh->requests - conn->requests); | |
688 conn->bosh->requests -= conn->requests; | |
689 conn->requests = 0; | |
690 } | |
654 if (conn->bosh->pipelining) | 691 if (conn->bosh->pipelining) |
655 /* Hmmmm, fall back to multiple connections */ | 692 /* Hmmmm, fall back to multiple connections */ |
656 conn->bosh->pipelining = FALSE; | 693 conn->bosh->pipelining = FALSE; |
657 | 694 |
658 if (++conn->bosh->failed_connections == MAX_FAILED_CONNECTIONS) { | 695 if (++conn->bosh->failed_connections == MAX_FAILED_CONNECTIONS) { |
949 len = strlen(data); | 986 len = strlen(data); |
950 | 987 |
951 ++conn->requests; | 988 ++conn->requests; |
952 ++conn->bosh->requests; | 989 ++conn->bosh->requests; |
953 | 990 |
991 if (purple_debug_is_unsafe() && purple_debug_is_verbose()) | |
992 /* Will contain passwords for SASL PLAIN and is verbose */ | |
993 purple_debug_misc("jabber", "BOSH: Sending %s\n", data); | |
994 | |
954 if (conn->writeh == 0) | 995 if (conn->writeh == 0) |
955 ret = http_connection_do_send(conn, data, len); | 996 ret = http_connection_do_send(conn, data, len); |
956 else { | 997 else { |
957 ret = -1; | 998 ret = -1; |
958 errno = EAGAIN; | 999 errno = EAGAIN; |