*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-02-01 17:42:20 +00:00
parent 1a198769cf
commit 268d96020e
3 changed files with 69 additions and 78 deletions

View File

@ -252,9 +252,6 @@ namespace libtorrent
bool support_extensions() const
{ return m_supports_extensions; }
const boost::posix_time::time_duration& last_piece_time() const
{ return m_last_piece_time; }
// a connection is local if it was initiated by us.
// if it was an incoming connection, it is remote
bool is_local() const
@ -523,10 +520,6 @@ namespace libtorrent
// message from this peer
boost::posix_time::ptime m_last_piece;
// the time it took for the peer to send the piece
// message
boost::posix_time::time_duration m_last_piece_time;
// this is true if this connection has been added
// to the list of connections that will be closed.
bool m_disconnecting;

View File

@ -106,7 +106,6 @@ namespace libtorrent
, m_trust_points(0)
, m_num_invalid_requests(0)
, m_last_piece(boost::posix_time::second_clock::local_time())
, m_last_piece_time(boost::posix_time::seconds(0))
, m_disconnecting(false)
, m_became_uninterested(boost::posix_time::second_clock::local_time())
, m_became_uninteresting(boost::posix_time::second_clock::local_time())
@ -171,7 +170,6 @@ namespace libtorrent
, m_trust_points(0)
, m_num_invalid_requests(0)
, m_last_piece(boost::posix_time::second_clock::local_time())
, m_last_piece_time(boost::posix_time::seconds(0))
, m_disconnecting(false)
, m_became_uninterested(boost::posix_time::second_clock::local_time())
, m_became_uninteresting(boost::posix_time::second_clock::local_time())
@ -647,9 +645,6 @@ namespace libtorrent
if (m_recv_pos < m_packet_size) return;
m_last_piece_time = m_last_piece
- boost::posix_time::second_clock::local_time();
const char* ptr = &m_recv_buffer[1];
peer_request p;
p.piece = detail::read_int32(ptr);

View File

@ -63,7 +63,7 @@ namespace
{
// the limits of the download queue size
max_request_queue = 16,
min_request_queue = 4,
min_request_queue = 2,
// the amount of free upload allowed before
// the peer is choked
@ -157,78 +157,81 @@ namespace
// (then we can cancel those and request them
// from this peer instead)
peer_connection* peer = 0;
float min_weight = std::numeric_limits<float>::max();
// find the peer with the lowest download
// speed that also has a piece that this
// peer could send us
for (torrent::peer_iterator i = t.begin();
i != t.end();
++i)
while (num_requests > 0)
{
// don't try to take over blocks from ourself
if (i->second == &c)
continue;
peer_connection* peer = 0;
float min_weight = std::numeric_limits<float>::max();
// find the peer with the lowest download
// speed that also has a piece that this
// peer could send us
for (torrent::peer_iterator i = t.begin();
i != t.end();
++i)
{
// don't try to take over blocks from ourself
if (i->second == &c)
continue;
// ignore all peers in the ignore list
if (std::find(ignore.begin(), ignore.end(), i->second) != ignore.end())
continue;
// ignore all peers in the ignore list
if (std::find(ignore.begin(), ignore.end(), i->second) != ignore.end())
continue;
const std::deque<piece_block>& queue = i->second->download_queue();
const int queue_size = (int)i->second->download_queue().size();
const std::deque<piece_block>& queue = i->second->download_queue();
const int queue_size = (int)i->second->download_queue().size();
const float weight = queue_size == 0
? std::numeric_limits<float>::max()
: i->second->statistics().down_peak() / queue_size;
if (weight < min_weight
&& std::find_first_of(
busy_pieces.begin()
, busy_pieces.end()
, queue.begin()
, queue.end()) != busy_pieces.end())
{
peer = i->second;
min_weight = weight;
}
}
if (peer == 0)
{
// we probably couldn't request the block because
// we are ignoring some peers
return;
}
// this peer doesn't have a faster connection than the
// slowest peer. Don't take over any blocks
const int queue_size = (int)c.download_queue().size();
const float weight = queue_size == 0
? std::numeric_limits<float>::max()
: i->second->statistics().down_peak() / queue_size;
: c.statistics().down_peak() / queue_size;
if (weight < min_weight
&& std::find_first_of(
busy_pieces.begin()
, busy_pieces.end()
, queue.begin()
, queue.end()) != busy_pieces.end())
{
peer = i->second;
min_weight = weight;
}
if (weight <= min_weight) return;
// find a suitable block to take over from this peer
std::deque<piece_block>::const_reverse_iterator common_block =
std::find_first_of(
peer->download_queue().rbegin()
, peer->download_queue().rend()
, busy_pieces.begin()
, busy_pieces.end());
assert(common_block != peer->download_queue().rend());
piece_block block = *common_block;
peer->send_cancel(block);
c.send_request(block);
// the one we interrupted may need to request a new piece
// make sure it doesn't take over a block from the peer
// that just took over its block
ignore.push_back(&c);
request_a_block(t, *peer, ignore);
num_requests--;
}
if (peer == 0)
{
// we probably couldn't request the block because
// we are ignoring some peers
return;
}
// this peer doesn't have a faster connection than the
// slowest peer. Don't take over any blocks
const int queue_size = (int)c.download_queue().size();
const float weight = queue_size == 0
? std::numeric_limits<float>::max()
: c.statistics().down_peak() / queue_size;
if (weight <= min_weight) return;
// find a suitable block to take over from this peer
std::deque<piece_block>::const_reverse_iterator common_block =
std::find_first_of(
peer->download_queue().rbegin()
, peer->download_queue().rend()
, busy_pieces.begin()
, busy_pieces.end());
assert(common_block != peer->download_queue().rend());
piece_block block = *common_block;
peer->send_cancel(block);
c.send_request(block);
// the one we interrupted may need to request a new piece
// make sure it doesn't take over a block from the peer
// that just took over its block
ignore.push_back(&c);
request_a_block(t, *peer, ignore);
num_requests--;
}