comparison libpurple/protocols/jabber/bosh.c @ 31132:b7e2cddaac7a

jabber: Improved BOSH logging some. Refs #13008
author Paul Aurich <paul@darkrain42.org>
date Mon, 10 Jan 2011 01:28:31 +0000
parents 7c871249318b
children dbd0012e72cb
comparison
equal deleted inserted replaced
31131:14a36bcf6704 31132:b7e2cddaac7a
298 } 298 }
299 299
300 /* Third loop, look for one that's NULL and create a new connection */ 300 /* Third loop, look for one that's NULL and create a new connection */
301 for (i = 0; i < NUM_HTTP_CONNECTIONS; ++i) { 301 for (i = 0; i < NUM_HTTP_CONNECTIONS; ++i) {
302 if (!conn->connections[i]) { 302 if (!conn->connections[i]) {
303 purple_debug_info("jabber", "bosh: Creating and connecting new httpconn\n");
304 conn->connections[i] = jabber_bosh_http_connection_init(conn); 303 conn->connections[i] = jabber_bosh_http_connection_init(conn);
304 purple_debug_info("jabber", "bosh: Creating and connecting new httpconn "
305 "(%i, %p)\n", i, conn->connections[i]);
305 306
306 http_connection_connect(conn->connections[i]); 307 http_connection_connect(conn->connections[i]);
307 return NULL; 308 return NULL;
308 } 309 }
309 } 310 }
673 /* Hmmmm, fall back to multiple connections */ 674 /* Hmmmm, fall back to multiple connections */
674 conn->bosh->pipelining = FALSE; 675 conn->bosh->pipelining = FALSE;
675 if (conn->bosh->connections[1] == NULL) { 676 if (conn->bosh->connections[1] == NULL) {
676 conn->bosh->connections[1] = jabber_bosh_http_connection_init(conn->bosh); 677 conn->bosh->connections[1] = jabber_bosh_http_connection_init(conn->bosh);
677 http_connection_connect(conn->bosh->connections[1]); 678 http_connection_connect(conn->bosh->connections[1]);
679 } else {
680 /* Shouldn't happen; this should be the only place pipelining
681 * is turned off.
682 */
683 g_warn_if_reached();
678 } 684 }
679 } 685 }
680 686
681 if (++conn->bosh->failed_connections == MAX_FAILED_CONNECTIONS) { 687 if (++conn->bosh->failed_connections == MAX_FAILED_CONNECTIONS) {
682 purple_connection_error_reason(conn->bosh->js->gc, 688 purple_connection_error_reason(conn->bosh->js->gc,
789 } 795 }
790 } while (cnt > 0); 796 } while (cnt > 0);
791 797
792 if (cnt == 0 || (cnt < 0 && errno != EAGAIN)) { 798 if (cnt == 0 || (cnt < 0 && errno != EAGAIN)) {
793 if (cnt < 0) 799 if (cnt < 0)
794 purple_debug_info("jabber", "bosh read=%d, errno=%d, error=%s\n", 800 purple_debug_info("jabber", "BOSH (%p) read=%d, errno=%d, error=%s\n",
795 cnt, errno, g_strerror(errno)); 801 conn, cnt, errno, g_strerror(errno));
796 else 802 else
797 purple_debug_info("jabber", "bosh server closed the connection\n"); 803 purple_debug_info("jabber", "BOSH server closed the connection (%p)\n",
804 conn);
798 805
799 /* 806 /*
800 * If the socket is closed, the processing really needs to know about 807 * If the socket is closed, the processing really needs to know about
801 * it. Handle that now. 808 * it. Handle that now.
802 */ 809 */
909 if (conn->psc) 916 if (conn->psc)
910 ret = purple_ssl_write(conn->psc, data, len); 917 ret = purple_ssl_write(conn->psc, data, len);
911 else 918 else
912 ret = write(conn->fd, data, len); 919 ret = write(conn->fd, data, len);
913 920
921 if (purple_debug_is_verbose())
922 purple_debug_misc("jabber", "BOSH (%p): wrote %d bytes\n", conn, ret);
923
914 return ret; 924 return ret;
915 } 925 }
916 926
917 static void 927 static void
918 http_connection_send_cb(gpointer data, gint source, PurpleInputCondition cond) 928 http_connection_send_cb(gpointer data, gint source, PurpleInputCondition cond)
973 ++conn->requests; 983 ++conn->requests;
974 ++conn->bosh->requests; 984 ++conn->bosh->requests;
975 985
976 if (purple_debug_is_unsafe() && purple_debug_is_verbose()) 986 if (purple_debug_is_unsafe() && purple_debug_is_verbose())
977 /* Will contain passwords for SASL PLAIN and is verbose */ 987 /* Will contain passwords for SASL PLAIN and is verbose */
978 purple_debug_misc("jabber", "BOSH: Sending %s\n", data); 988 purple_debug_misc("jabber", "BOSH (%p): Sending %s\n", conn, data);
989 else if (purple_debug_is_verbose())
990 purple_debug_misc("jabber", "BOSH (%p): Sending request of "
991 "%" G_GSIZE_FORMAT "bytes.", conn, len);
979 992
980 if (conn->writeh == 0) 993 if (conn->writeh == 0)
981 ret = http_connection_do_send(conn, data, len); 994 ret = http_connection_do_send(conn, data, len);
982 else { 995 else {
983 ret = -1; 996 ret = -1;