diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 4a16ae7b2..15a9be909 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4506,7 +4506,7 @@ namespace libtorrent { shared_ptr t = m_torrent.lock(); int priority; - if (m_ses.m_settings.choking_algorithm == session_settings::bittyrant_choker + if (t && m_ses.m_settings.choking_algorithm == session_settings::bittyrant_choker && !t->upload_mode() && !t->is_upload_only()) { // when we use the bittyrant choker, the priority of a peer @@ -4533,7 +4533,7 @@ namespace libtorrent { priority = 1 + is_interesting() * 2 + m_requests_in_buffer.size(); if (priority > 255) priority = 255; - priority += t->priority() << 8; + priority += t ? t->priority() << 8 : 0; } TORRENT_ASSERT(priority <= 0xffff); @@ -4545,9 +4545,9 @@ namespace libtorrent , int(m_send_buffer.size()), priority , bwc1, bwc2, bwc3, bwc4 , (bwc1?bwc1->throttle():0) - , (bwc2?bwc2->throttle():0) - , (bwc3?bwc3->throttle():0) - , (bwc4?bwc4->throttle():0) + , (bwc2?bwc2->throttle():0) + , (bwc3?bwc3->throttle():0) + , (bwc4?bwc4->throttle():0) , m_ignore_bandwidth_limits); #endif return m_ses.m_upload_rate.request_bandwidth(self() @@ -4571,14 +4571,14 @@ namespace libtorrent , int(m_download_queue.size() * 16 * 1024 + 30), m_priority , bwc1, bwc2, bwc3, bwc4 , (bwc1?bwc1->throttle():0) - , (bwc2?bwc2->throttle():0) - , (bwc3?bwc3->throttle():0) - , (bwc4?bwc4->throttle():0) + , (bwc2?bwc2->throttle():0) + , (bwc3?bwc3->throttle():0) + , (bwc4?bwc4->throttle():0) , m_ignore_bandwidth_limits); #endif TORRENT_ASSERT(m_priority <= 255); - int priority = m_priority + (t->priority() << 8); + int priority = m_priority + (t ? (t->priority() << 8) : 0); TORRENT_ASSERT(m_outstanding_bytes >= 0); TORRENT_ASSERT((m_channel_state[download_channel] & peer_info::bw_limit) == 0); @@ -4606,8 +4606,7 @@ namespace libtorrent if (m_quota[upload_channel] == 0 && !m_send_buffer.empty() - && !m_connecting - && t) + && !m_connecting) { int ret = 0; bool utp = m_socket->get() != 0; @@ -4620,7 +4619,7 @@ namespace libtorrent // from the bandwidth manager ret = request_upload_bandwidth( &m_ses.m_upload_channel - , &t->m_bandwidth_channel[upload_channel] + , t ? &t->m_bandwidth_channel[upload_channel] : 0 , &m_bandwidth_channel[upload_channel] , !utp ? &m_ses.m_tcp_upload_channel : 0); } @@ -4760,8 +4759,7 @@ namespace libtorrent shared_ptr t = m_torrent.lock(); if (m_quota[download_channel] == 0 - && !m_connecting - && t) + && !m_connecting) { int ret = 0; bool utp = m_socket->get() != 0; @@ -4774,7 +4772,7 @@ namespace libtorrent // request bandwidth from the bandwidth manager ret = request_download_bandwidth( &m_ses.m_download_channel - , &t->m_bandwidth_channel[download_channel] + , t ? &t->m_bandwidth_channel[download_channel] : 0 , &m_bandwidth_channel[download_channel] , !utp ? &m_ses.m_tcp_download_channel : 0); } diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index 99d2b1f6f..f87969b68 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -263,6 +263,7 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe session_settings sett; sett.allow_multiple_connections_per_ip = false; + sett.ignore_limits_on_local_network = false; if (test_allowed_fast) {