diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 1e065acc3..7b3eb9231 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -724,15 +724,19 @@ int main(int ac, char* av[]) std::stringstream out; for (handles_t::iterator i = handles.begin(); - i != handles.end(); ++i) + i != handles.end();) { torrent_handle& h = i->second; if (!h.is_valid()) { - handles.erase(i); - --i; + handles.erase(i++); continue; } + else + { + ++i; + } + out << "name: " << esc("37"); if (h.has_metadata()) out << h.get_torrent_info().name(); else out << "-"; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index eea438340..937b0f3a1 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -792,7 +792,7 @@ namespace libtorrent return; } - if (m_requests.size() > m_ses.m_settings.max_allowed_request_queue) + if (int(m_requests.size()) > m_ses.m_settings.max_allowed_request_queue) { // don't allow clients to abuse our // memory consumption. @@ -1468,7 +1468,7 @@ namespace libtorrent // if we have downloaded more than one piece more // than we have uploaded OR if we are a seed // have an unlimited upload rate - if(!m_send_buffer[m_current_send_buffer].empty() + if(send_buffer_size() > 0 || (!m_requests.empty() && !is_choked())) m_ul_bandwidth_quota.max = resource_request::inf; else @@ -1738,7 +1738,7 @@ namespace libtorrent assert(m_reading); assert(m_last_read_size > 0); - assert(m_last_read_size >= bytes_transferred); + assert(m_last_read_size >= int(bytes_transferred)); m_reading = false; // correct the dl quota usage, if not all of the buffer was actually read m_dl_bandwidth_quota.used -= m_last_read_size - bytes_transferred; @@ -1803,7 +1803,8 @@ namespace libtorrent // if we have requests or pending data to be sent or announcements to be made // we want to send data return ((!m_requests.empty() && !m_choked) - || !m_send_buffer[m_current_send_buffer].empty()) + || !m_send_buffer[m_current_send_buffer].empty() + || !m_send_buffer[(m_current_send_buffer + 1) & 1].empty()) && m_ul_bandwidth_quota.left() > 0 && !m_connecting; } @@ -1955,8 +1956,8 @@ namespace libtorrent } } - assert(m_write_pos <= m_send_buffer[ - (m_current_send_buffer + 1) & 1].size()); + assert(m_write_pos <= int(m_send_buffer[ + (m_current_send_buffer + 1) & 1].size())); } #endif diff --git a/src/session.cpp b/src/session.cpp index 8fbe1cda9..7e38543e1 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -1047,16 +1047,6 @@ namespace libtorrent session_impl::mutex_t::scoped_lock l(m_impl.m_mutex); std::fill(m_impl.m_extension_enabled, m_impl.m_extension_enabled + num_supported_extensions, false); - - static char const printable[] - = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.!~*'()"; - - // remove the 'ext' sufix in the peer_id - for (unsigned char* i = m_impl.m_peer_id.begin() + 17; - i != m_impl.m_peer_id.end(); ++i) - { - *i = printable[rand() % (sizeof(printable)-1)]; - } } void session::set_ip_filter(ip_filter const& f) diff --git a/test/test_metadata_extension.cpp b/test/test_metadata_extension.cpp index 4d1d33fa1..55c4b0d22 100644 --- a/test/test_metadata_extension.cpp +++ b/test/test_metadata_extension.cpp @@ -17,7 +17,9 @@ void test_transfer(char const* tracker_url, libtorrent::torrent_info const& t) using namespace libtorrent; session ses1; + ses1.set_severity_level(alert::debug); session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49000, 50000)); + ses2.set_severity_level(alert::debug); // they should not use the same save dir, because the // file pool will complain if two torrents are trying to @@ -47,12 +49,21 @@ void test_transfer(char const* tracker_url, libtorrent::torrent_info const& t) // make sure this function can be called on // torrents without metadata tor2.status(); + std::auto_ptr a; + a = ses1.pop_alert(); + if (a.get()) + std::cerr << "ses1: " << a->msg() << "\n"; + + a = ses2.pop_alert(); + if (a.get()) + std::cerr << "ses2: " << a->msg() << "\n"; + if (tor2.has_metadata()) break; sleep(100); } - std::cerr << "metadata received. waiting for transfer to complete\n"; TEST_CHECK(tor2.has_metadata()); + std::cerr << "metadata received. waiting for transfer to complete\n"; for (int i = 0; i < 50; ++i) { @@ -61,8 +72,8 @@ void test_transfer(char const* tracker_url, libtorrent::torrent_info const& t) sleep(100); } - std::cerr << "done\n"; TEST_CHECK(tor2.is_seed()); + std::cerr << "done\n"; } int test_main()