diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 8d8d7f27f..8c3440e41 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -292,7 +292,7 @@ namespace libtorrent { m_holepunch_mode = true; #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << "*** HOLEPUNCH MODE ***\n"; + peer_log("*** HOLEPUNCH MODE ***"); #endif } @@ -432,7 +432,7 @@ namespace libtorrent int est_reciprocation_rate() const { return m_est_reciprocation_rate; } #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING - void peer_log(char const* fmt, ...); + void peer_log(char const* fmt, ...) const; boost::shared_ptr m_logger; #endif @@ -520,7 +520,7 @@ namespace libtorrent downloading_piece_progress() const { #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << "downloading_piece_progress() dispatched to the base class!\n"; + peer_log("*** downloading_piece_progress() dispatched to the base class!"); #endif return boost::optional(); } diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 667714253..425db78dc 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -117,7 +117,7 @@ namespace libtorrent #endif { #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << "*** bt_peer_connection\n"; + peer_log("*** bt_peer_connection"); #endif #ifdef TORRENT_DEBUG @@ -270,8 +270,7 @@ namespace libtorrent TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() - << " ==> DHT_PORT [ " << listen_port << " ]\n"; + peer_log("==> DHT_PORT [ %d ]", listen_port); #endif char msg[] = {0,0,0,3, msg_dht_port, 0, 0}; char* ptr = msg + 5; @@ -287,8 +286,7 @@ namespace libtorrent m_sent_bitfield = true; #endif #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() - << " ==> HAVE_ALL\n"; + peer_log("==> HAVE_ALL"); #endif char msg[] = {0,0,0,1, msg_have_all}; send_buffer(msg, sizeof(msg)); @@ -302,8 +300,7 @@ namespace libtorrent m_sent_bitfield = true; #endif #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() - << " ==> HAVE_NONE\n"; + peer_log("==> HAVE_NONE"); #endif char msg[] = {0,0,0,1, msg_have_none}; send_buffer(msg, sizeof(msg)); @@ -414,7 +411,7 @@ namespace libtorrent #ifdef TORRENT_VERBOSE_LOGGING if (is_local()) - (*m_logger) << " initiating encrypted handshake\n"; + peer_log("*** initiating encrypted handshake"); #endif m_dh_key_exchange.reset(new (std::nothrow) dh_key_exchange); @@ -427,7 +424,7 @@ namespace libtorrent int pad_size = std::rand() % 512; #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << " pad size: " << pad_size << "\n"; + peer_log(" pad size: %d", pad_size); #endif buffer::interval send_buf = allocate_send_buffer(dh_key_len + pad_size); @@ -449,7 +446,7 @@ namespace libtorrent setup_send(); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << " sent DH key\n"; + peer_log(" sent DH key"); #endif } @@ -521,13 +518,9 @@ namespace libtorrent crypto_provide = 0x01; #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << " crypto provide : [ "; - if (allowed_enc_level == pe_settings::both) - (*m_logger) << "plaintext rc4 ]\n"; - else if (allowed_enc_level == pe_settings::rc4) - (*m_logger) << "rc4 ]\n"; - else if (allowed_enc_level == pe_settings::plaintext) - (*m_logger) << "plaintext ]\n"; + char const* level[] = {"plaintext", "rc4", "plaintext rc4"}; + peer_log(" crypto provide : [ %s ]" + , level[allowed_enc_level]); #endif write_pe_vc_cryptofield(send_buf, crypto_provide, pad_size); @@ -574,11 +567,8 @@ namespace libtorrent m_rc4_encrypted = false; #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << " crypto select : [ "; - if (crypto_select == 0x01) - (*m_logger) << "plaintext ]\n"; - else - (*m_logger) << "rc4 ]\n"; + peer_log(" crypto select : [ %s ]" + , (crypto_select == 0x01) ? "plaintext" : "rc4"); #endif } @@ -653,7 +643,7 @@ namespace libtorrent } #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << " computed RC4 keys\n"; + peer_log(" computed RC4 keys"); #endif } @@ -837,14 +827,16 @@ namespace libtorrent *(i.begin + 7) |= 0x04; #ifdef TORRENT_VERBOSE_LOGGING + std::string bitmask; for (int k = 0; k < 8; ++k) { for (int j = 0; j < 8; ++j) { - if (i.begin[k] & (0x80 >> j)) (*m_logger) << "1"; - else (*m_logger) << "0"; + if (i.begin[k] & (0x80 >> j)) bitmask += '1'; + else bitmask += '0'; } } + peer_log("extension bits: %s", bitmask.c_str()); #endif i.begin += 8; @@ -862,7 +854,7 @@ namespace libtorrent TORRENT_ASSERT(i.begin == i.end); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " ==> HANDSHAKE\n"; + peer_log("==> HANDSHAKE"); #endif setup_send(); } @@ -911,7 +903,7 @@ namespace libtorrent INVARIANT_CHECK; #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " <== KEEPALIVE\n"; + peer_log("<== KEEPALIVE"); #endif incoming_keepalive(); } @@ -1225,8 +1217,8 @@ namespace libtorrent } #ifdef TORRENT_VERBOSE_LOGGING -// (*m_logger) << time_now_string() << " <== PIECE_FRAGMENT p: " << p.piece -// << " start: " << p.start << " length: " << p.length << "\n"; +// peer_log("<== PIECE_FRAGMENT p: %d start: %d length: %d" +// , p.piece, p.start, p.length); #endif if (recv_pos - received < header_size && recv_pos >= header_size) @@ -1245,7 +1237,7 @@ namespace libtorrent if (merkle && list_size > 0) { #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " <== HASHPIECE " << p.piece << " list: " << list_size << " "; + peer_log("<== HASHPIECE [ piece: %d list: %d ]", p.piece, list_size); #endif lazy_entry hash_list; error_code ec; @@ -1274,16 +1266,9 @@ namespace libtorrent || e->list_at(1)->type() != lazy_entry::string_t || e->list_at(1)->string_length() != 20) continue; -#ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << " " << e->list_int_value_at(0) << ": " - << sha1_hash(e->list_at(1)->string_ptr()); -#endif nodes.insert(std::make_pair(int(e->list_int_value_at(0)) , sha1_hash(e->list_at(1)->string_ptr()))); } -#ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << "\n"; -#endif if (!nodes.empty() && !t->add_merkle_nodes(nodes, p.piece)) { disconnect(errors::invalid_hash_piece, 2); @@ -1496,10 +1481,9 @@ namespace libtorrent #if defined TORRENT_VERBOSE_LOGGING error_code ec; static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"}; - (*m_logger) << time_now_string() << " <== HOLEPUNCH [ msg:" - << (msg_type >= 0 && msg_type < 3 ? hp_msg_name[msg_type] : "unknown message type") - << " from:" << remote().address().to_string(ec) - << " to: unknown address type ]\n"; + peer_log("<== HOLEPUNCH [ msg: %s from %s to: unknown address type ]" + , (msg_type >= 0 && msg_type < 3 ? hp_msg_name[msg_type] : "unknown message type") + , print_address(remote().address()).c_str()); #endif return; // unknown address type @@ -1513,9 +1497,8 @@ namespace libtorrent case hp_rendezvous: // rendezvous { #if defined TORRENT_VERBOSE_LOGGING - error_code ec; - (*m_logger) << time_now_string() << " <== HOLEPUNCH [ msg:rendezvous" - << " to:" << ep.address().to_string(ec) << " ]\n"; + peer_log("<== HOLEPUNCH [ msg: rendezvous to: %s ]" + , print_address(ep.address()).c_str()); #endif // this peer is asking us to introduce it to // the peer at 'ep'. We need to find which of @@ -1548,9 +1531,8 @@ namespace libtorrent if (p == 0 || p->connection) { #if defined TORRENT_VERBOSE_LOGGING - error_code ec; - (*m_logger) << time_now_string() << " <== HOLEPUNCH [ msg:connect" - << " to:" << ep.address().to_string(ec) << " error:failed to add peer ]\n"; + peer_log("<== HOLEPUNCH [ msg:connect to: %s error: failed to add peer ]" + , print_address(ep.address()).c_str()); #endif // we either couldn't add this peer, or it's // already connected. Just ignore the connect message @@ -1559,9 +1541,8 @@ namespace libtorrent if (p->banned) { #if defined TORRENT_VERBOSE_LOGGING - error_code ec; - (*m_logger) << time_now_string() << " <== HOLEPUNCH [ msg:connect" - << " to:" << ep.address().to_string(ec) << " error:peer banned ]\n"; + peer_log("<== HOLEPUNCH [ msg:connect to: %s error: peer banned ]" + , print_address(ep.address()).c_str()); #endif // this peer is banned, don't connect to it break; @@ -1578,9 +1559,8 @@ namespace libtorrent if (p->connection) p->connection->set_holepunch_mode(); #if defined TORRENT_VERBOSE_LOGGING - error_code ec; - (*m_logger) << time_now_string() << " <== HOLEPUNCH [ msg:connect" - << " to:" << ep.address().to_string(ec) << " ]\n"; + peer_log("<== HOLEPUNCH [ msg:connect to: %s ]" + , print_address(ep.address()).c_str()); #endif } break; case hp_failed: @@ -1589,10 +1569,8 @@ namespace libtorrent #if defined TORRENT_VERBOSE_LOGGING error_code ec; char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"}; - (*m_logger) << time_now_string() << " <== HOLEPUNCH [ msg:failed" - " error:" << error << - " msg:" << ((error >= 0 && error < 4)?err_msg[error]:"unknown message id") << - " ]\n"; + peer_log("<== HOLEPUNCH [ msg:failed error: %d msg: %s ]", error + , ((error >= 0 && error < 4)?err_msg[error]:"unknown message id")); #endif // #error deal with holepunch errors } break; @@ -1600,9 +1578,8 @@ namespace libtorrent default: { error_code ec; - (*m_logger) << time_now_string() << " <== HOLEPUNCH [" - " msg:unknown message type (" << msg_type << ")" - << " to:" << ep.address().to_string(ec) << " ]\n"; + peer_log("<== HOLEPUNCH [ msg: unknown message type (%d) to: %s ]" + , msg_type, print_address(ep.address()).c_str()); } #endif } @@ -1621,11 +1598,10 @@ namespace libtorrent error_code ec; static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"}; static const char* hp_error_string[] = {"", "no such peer", "not connected", "no support", "no self"}; - (*m_logger) << time_now_string() << " ==> HOLEPUNCH [ msg:" - << (type >= 0 && type < 3 ? hp_msg_name[type] : "unknown message type") - << " to:" << ep.address().to_string(ec) - << " error:" << hp_error_string[error] - << " ]\n"; + peer_log("==> HOLEPUNCH [ msg: %s to: %s error: %s ]" + , (type >= 0 && type < 3 ? hp_msg_name[type] : "unknown message type") + , print_address(ep.address()).c_str() + , hp_error_string[error]); #endif if (type == hp_failed) { @@ -1684,7 +1660,7 @@ namespace libtorrent if (!packet_finished()) return; bool ul = detail::read_uint8(recv_buffer.begin); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " <== UPLOAD_ONLY [ " << (ul?"true":"false") << " ]\n"; + peer_log("<== UPLOAD_ONLY [ %s ]", (ul?"true":"false")); #endif set_upload_only(ul); return; @@ -1699,9 +1675,8 @@ namespace libtorrent #ifdef TORRENT_VERBOSE_LOGGING if (packet_finished()) - (*m_logger) << time_now_string() << " <== EXTENSION MESSAGE [" - " msg:" << extended_id << - " size:" << packet_size() << " ]\n"; + peer_log("<== EXTENSION MESSAGE [ msg: %d size: %d ]" + , extended_id, packet_size()); #endif #ifndef TORRENT_DISABLE_EXTENSIONS @@ -1748,14 +1723,14 @@ namespace libtorrent if (root.type() != lazy_entry::dict_t) { #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " invalid extended handshake: " << ec.message() - << "pos: " << pos << "\n"; + peer_log(" invalid extended handshake: %s pos: %d" + , ec.message().c_str(), pos); #endif return; } #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " <== EXTENDED HANDSHAKE: \n" << root; + peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str()); #endif #ifndef TORRENT_DISABLE_EXTENSIONS @@ -2021,7 +1996,7 @@ namespace libtorrent { // don't send a bitfield if we don't have any pieces #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " *** NOT SENDING BITFIELD\n"; + peer_log(" *** NOT SENDING BITFIELD"); #endif #ifdef TORRENT_DEBUG m_sent_bitfield = true; @@ -2090,17 +2065,15 @@ namespace libtorrent TORRENT_ASSERT(i.end - i.begin == (num_pieces + 7) / 8); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " ==> BITFIELD "; std::string bitfield_string; - bitfield_string.resize(num_pieces + 1); + bitfield_string.resize(num_pieces); for (int k = 0; k < num_pieces; ++k) { if (i.begin[k / 8] & (0x80 >> (k % 8))) bitfield_string[k] = '1'; else bitfield_string[k] = '0'; } - bitfield_string[num_pieces] = '\n'; - (*m_logger) << bitfield_string; + peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str()); #endif #ifdef TORRENT_DEBUG m_sent_bitfield = true; @@ -2112,11 +2085,10 @@ namespace libtorrent { for (int i = 0; i < num_lazy_pieces; ++i) { - write_have(lazy_pieces[i]); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() - << " ==> HAVE [ piece: " << lazy_pieces[i] << "]\n"; + peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]); #endif + write_have(lazy_pieces[i]); } // TODO: if we're finished, send upload_only message } @@ -2131,7 +2103,7 @@ namespace libtorrent INVARIANT_CHECK; #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " ==> EXTENSIONS\n"; + peer_log("==> EXTENSIONS"); #endif TORRENT_ASSERT(m_supports_extensions); TORRENT_ASSERT(m_sent_handshake); @@ -2231,7 +2203,7 @@ namespace libtorrent #if defined TORRENT_VERBOSE_LOGGING && TORRENT_USE_IOSTREAM std::stringstream handshake_str; handshake.print(handshake_str); - (*m_logger) << time_now_string() << " ==> EXTENDED HANDSHAKE: \n" << handshake_str.str(); + peer_log("==> EXTENDED HANDSHAKE: %s", handshake_str.str().c_str()); #endif setup_send(); @@ -2438,7 +2410,7 @@ namespace libtorrent } #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " received DH key\n"; + peer_log("*** received DH key"); #endif TORRENT_ASSERT(!m_rc4_encrypted || send_buffer_size() == m_encrypted_bytes); @@ -2541,8 +2513,8 @@ namespace libtorrent { std::size_t bytes_processed = syncoffset + 20; #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string << " sync point (hash) found at offset " - << m_sync_bytes_read + bytes_processed - 20 << "\n"; + peer_log("*** sync point (hash) found at offset %d" + , m_sync_bytes_read + bytes_processed - 20); #endif m_state = read_pe_skey_vc; // skey,vc - 28 bytes @@ -2592,7 +2564,7 @@ namespace libtorrent init_pe_RC4_handler(m_dh_key_exchange->get_secret(), ti.info_hash()); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " stream key found, torrent located.\n"; + peer_log("*** stream key found, torrent located"); #endif break; } @@ -2617,7 +2589,7 @@ namespace libtorrent } #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " verification constant found\n"; + peer_log("*** verification constant found"); #endif m_state = read_pe_cryptofield; reset_recv_buffer(4 + 2); @@ -2681,8 +2653,8 @@ namespace libtorrent { std::size_t bytes_processed = syncoffset + 8; #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " sync point (verification constant) found at offset " - << m_sync_bytes_read + bytes_processed - 8 << "\n"; + peer_log("*** sync point (verification constant) found at offset %d" + , m_sync_bytes_read + bytes_processed - 8); #endif int transferred_used = bytes_processed - recv_buffer.left() + bytes_transferred; TORRENT_ASSERT(transferred_used <= int(bytes_transferred)); @@ -2716,16 +2688,10 @@ namespace libtorrent int crypto_field = detail::read_int32(recv_buffer.begin); #ifdef TORRENT_VERBOSE_LOGGING - if (!is_local()) - (*m_logger) << time_now_string() << " crypto provide : [ "; - else - (*m_logger) << time_now_string() << " crypto select : [ "; - - if (crypto_field & 0x01) - (*m_logger) << "plaintext "; - if (crypto_field & 0x02) - (*m_logger) << "rc4 "; - (*m_logger) << "]\n"; + peer_log("*** crypto %s : [%s%s ]" + , is_local() ? "select" : "provide" + , (crypto_field & 1) ? " plaintext" : "" + , (crypto_field & 2) ? " rc4" : ""); #endif if (!is_local()) @@ -2857,7 +2823,7 @@ namespace libtorrent } #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " len(IA) : " << len_ia << "\n"; + peer_log("*** len(IA) : %d", len_ia); #endif if (len_ia == 0) { @@ -2893,14 +2859,14 @@ namespace libtorrent m_RC4_handler->decrypt(wr_buf.begin, packet_size()); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " decrypted ia : " << packet_size() << " bytes\n"; + peer_log("*** decrypted ia : %d bytes", packet_size()); #endif if (!m_rc4_encrypted) { m_RC4_handler.reset(); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " destroyed rc4 keys\n"; + peer_log("*** destroyed rc4 keys"); #endif } @@ -2924,14 +2890,14 @@ namespace libtorrent wr_buf.begin += packet_size(); m_RC4_handler->decrypt(wr_buf.begin, wr_buf.left()); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " decrypted remaining " << wr_buf.left() << " bytes\n"; + peer_log("*** decrypted remaining %d bytes", wr_buf.left()); #endif } else // !m_rc4_encrypted { m_RC4_handler.reset(); #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " destroyed rc4 keys\n"; + peer_log("*** destroyed rc4 keys"); #endif } @@ -2980,7 +2946,7 @@ namespace libtorrent if (!m_encrypted && !is_local()) { #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " attempting encrypted connection\n"; + peer_log("*** attempting encrypted connection"); #endif m_state = read_pe_dhkey; cut_receive_buffer(0, dh_key_len); @@ -3007,7 +2973,7 @@ namespace libtorrent #endif #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " BitTorrent protocol\n"; + peer_log("<== BitTorrent protocol"); #endif m_state = read_info_hash; @@ -3026,21 +2992,21 @@ namespace libtorrent #ifdef TORRENT_VERBOSE_LOGGING + std::string extensions; + extensions.resize(8 * 8); for (int i=0; i < 8; ++i) { for (int j=0; j < 8; ++j) { - if (recv_buffer[i] & (0x80 >> j)) (*m_logger) << "1"; - else (*m_logger) << "0"; + if (recv_buffer[i] & (0x80 >> j)) extensions[i*8+j] = '1'; + else extensions[i*8+j] = '0'; } } - (*m_logger) << "\n"; - if (recv_buffer[7] & 0x01) - (*m_logger) << " supports DHT port message\n"; - if (recv_buffer[7] & 0x04) - (*m_logger) << " supports FAST extensions\n"; - if (recv_buffer[5] & 0x10) - (*m_logger) << " supports extensions protocol\n"; + peer_log("<== EXTENSIONS [ %s ext: %s%s%s]" + , extensions.c_str() + , (recv_buffer[7] & 0x01) ? "DHT " : "" + , (recv_buffer[7] & 0x04) ? "FAST " : "" + , (recv_buffer[5] & 0x10) ? "extension " : ""); #endif #ifndef DISABLE_EXTENSIONS @@ -3074,14 +3040,14 @@ namespace libtorrent , (const char*)t->torrent_file().info_hash().begin())) { #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " received invalid info_hash\n"; + peer_log("*** received invalid info_hash"); #endif disconnect(errors::invalid_info_hash, 2); return; } #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " info_hash received\n"; + peer_log("<<< info_hash received"); #endif } @@ -3127,10 +3093,8 @@ namespace libtorrent if (is_print(recv_buffer.begin[i])) ascii_pid[i] = recv_buffer.begin[i]; else ascii_pid[i] = '.'; } - char msg[200]; - snprintf(msg, 200, "received peer_id: %s client: %s\nas ascii: %s\n" + peer_log("<<< received peer_id: %s client: %s\nas ascii: %s\n" , hex_pid, identify_client(peer_id(recv_buffer.begin)).c_str(), ascii_pid); - (*m_logger) << msg; } #endif peer_id pid; @@ -3201,7 +3165,7 @@ namespace libtorrent #endif #ifdef TORRENT_VERBOSE_LOGGING - (*m_logger) << time_now_string() << " <== HANDSHAKE\n"; + peer_log("<== HANDSHAKE"); #endif // consider this a successful connection, reset the failcount if (peer_info_struct()) t->get_policy().set_failcount(peer_info_struct(), 0); diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index f5e3eb532..4d72e02f3 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -408,7 +408,7 @@ namespace libtorrent int retry_time = atol(std::string(recv_buffer.begin, recv_buffer.end).c_str()); if (retry_time <= 0) retry_time = 60; #ifdef TORRENT_VERBOSE_LOGGING - peer_log("retrying in %d seconds", retry_time); + peer_log("*** retrying in %d seconds", retry_time); #endif m_statistics.received_bytes(0, bytes_transferred); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index fbfd39970..101242482 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -613,7 +613,7 @@ namespace libtorrent } #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING - void peer_connection::peer_log(char const* fmt, ...) + void peer_connection::peer_log(char const* fmt, ...) const { if (!m_logger) return; @@ -4367,11 +4367,6 @@ namespace libtorrent // peers that we are not interested in are non-prioritized m_channel_state[upload_channel] = peer_info::bw_limit; - m_ses.m_upload_rate.request_bandwidth(self() - , (std::max)(m_send_buffer.size(), m_statistics.upload_rate() * 2 - / (1000 / m_ses.m_settings.tick_interval)) - , priority - , bwc1, bwc2, bwc3, bwc4); #ifdef TORRENT_VERBOSE_LOGGING peer_log("==> REQUEST_BANDWIDTH [ upload: %d prio: %d " "channels: %p %p %p %p limits: %d %d %d %d ignore: %d ]" @@ -4383,6 +4378,11 @@ namespace libtorrent , (bwc4?bwc4->throttle():0) , m_ignore_bandwidth_limits); #endif + m_ses.m_upload_rate.request_bandwidth(self() + , (std::max)(m_send_buffer.size(), m_statistics.upload_rate() * 2 + / (1000 / m_ses.m_settings.tick_interval)) + , priority + , bwc1, bwc2, bwc3, bwc4); } void peer_connection::request_download_bandwidth(