streaming fixes

This commit is contained in:
Arvid Norberg 2009-11-02 01:01:07 +00:00
parent 2897389409
commit 1c377b1807
2 changed files with 20 additions and 3 deletions

View File

@ -1109,6 +1109,20 @@ int main(int argc, char* argv[])
if (h.is_valid()) h.set_sequential_download(!h.is_sequential_download()); if (h.is_valid()) h.set_sequential_download(!h.is_sequential_download());
} }
if (c == 'o')
{
torrent_handle h = get_active_torrent(handles);
if (h.is_valid())
{
int num_pieces = h.get_torrent_info().num_pieces();
if (num_pieces > 300) num_pieces = 300;
for (int i = 0; i < num_pieces; ++i)
{
h.set_piece_deadline(i, seconds(i+5), torrent_handle::alert_when_available);
}
}
}
if (c == 'v') if (c == 'v')
{ {
torrent_handle h = get_active_torrent(handles); torrent_handle h = get_active_torrent(handles);

View File

@ -1091,6 +1091,7 @@ namespace libtorrent
} }
} }
m_request_queue.clear(); m_request_queue.clear();
m_queued_time_critical = 0;
} }
} }
@ -2561,9 +2562,8 @@ namespace libtorrent
bool peer_connection::can_request_time_critical() const bool peer_connection::can_request_time_critical() const
{ {
if (has_peer_choked() || !is_interesting()) return false; if (has_peer_choked() || !is_interesting()) return false;
if (m_desired_queue_size * 2 < if ((int)m_download_queue.size() + (int)m_request_queue.size()
- (int)m_download_queue.size() > m_desired_queue_size * 2) return false;
- (int)m_request_queue.size()) return false;
if (on_parole()) return false; if (on_parole()) return false;
return true; return true;
} }
@ -3077,6 +3077,7 @@ namespace libtorrent
m_request_queue.pop_back(); m_request_queue.pop_back();
} }
} }
m_queued_time_critical = 0;
t->remove_peer(this); t->remove_peer(this);
m_torrent.reset(); m_torrent.reset();
@ -3734,6 +3735,8 @@ namespace libtorrent
= m_request_queue.begin() + (prev_request_queue - 1); = m_request_queue.begin() + (prev_request_queue - 1);
r = *i; r = *i;
m_request_queue.erase(i); m_request_queue.erase(i);
if (prev_request_queue <= m_queued_time_critical)
--m_queued_time_critical;
} }
else else
{ {