made end-game mode less aggressive
This commit is contained in:
parent
d892198a40
commit
f31e670fc2
|
@ -119,6 +119,7 @@ release 0.14.9
|
||||||
* fixed DHT bootstrapping issue
|
* fixed DHT bootstrapping issue
|
||||||
* fixed UDP over SOCKS5 issue
|
* fixed UDP over SOCKS5 issue
|
||||||
* added support for "corrupt" tracker announce
|
* added support for "corrupt" tracker announce
|
||||||
|
* made end-game mode less aggressive
|
||||||
|
|
||||||
release 0.14.8
|
release 0.14.8
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/session_settings.hpp"
|
#include "libtorrent/session_settings.hpp"
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
|
#include "libtorrent/time.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -139,8 +140,9 @@ namespace libtorrent
|
||||||
|
|
||||||
struct downloading_piece
|
struct downloading_piece
|
||||||
{
|
{
|
||||||
downloading_piece(): finished(0), writing(0), requested(0) {}
|
downloading_piece(): last_request(min_time()), finished(0), writing(0), requested(0) {}
|
||||||
piece_state_t state;
|
piece_state_t state;
|
||||||
|
ptime last_request;
|
||||||
|
|
||||||
// the index of the piece
|
// the index of the piece
|
||||||
int index;
|
int index;
|
||||||
|
@ -278,6 +280,7 @@ namespace libtorrent
|
||||||
void mark_as_finished(piece_block block, void* peer);
|
void mark_as_finished(piece_block block, void* peer);
|
||||||
void write_failed(piece_block block);
|
void write_failed(piece_block block);
|
||||||
int num_peers(piece_block block) const;
|
int num_peers(piece_block block) const;
|
||||||
|
ptime last_request(int piece) const;
|
||||||
|
|
||||||
// returns information about the given piece
|
// returns information about the given piece
|
||||||
void piece_info(int index, piece_picker::downloading_piece& st) const;
|
void piece_info(int index, piece_picker::downloading_piece& st) const;
|
||||||
|
|
|
@ -2012,6 +2012,7 @@ namespace libtorrent
|
||||||
info.peer = peer;
|
info.peer = peer;
|
||||||
info.num_peers = 1;
|
info.num_peers = 1;
|
||||||
++dp.requested;
|
++dp.requested;
|
||||||
|
dp.last_request = time_now();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2036,6 +2037,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
++info.num_peers;
|
++info.num_peers;
|
||||||
if (i->state == none) i->state = state;
|
if (i->state == none) i->state = state;
|
||||||
|
i->last_request = time_now();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2058,6 +2060,23 @@ namespace libtorrent
|
||||||
return info.num_peers;
|
return info.num_peers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptime piece_picker::last_request(int piece) const
|
||||||
|
{
|
||||||
|
TORRENT_ASSERT(piece >= 0);
|
||||||
|
TORRENT_ASSERT(piece < (int)m_piece_map.size());
|
||||||
|
|
||||||
|
piece_pos const& p = m_piece_map[piece];
|
||||||
|
if (!p.downloading) return min_time();
|
||||||
|
|
||||||
|
std::vector<downloading_piece>::const_iterator i
|
||||||
|
= std::find_if(m_downloads.begin(), m_downloads.end(), has_index(piece));
|
||||||
|
TORRENT_ASSERT(i != m_downloads.end());
|
||||||
|
// just to play it safe
|
||||||
|
if (i == m_downloads.end()) return min_time();
|
||||||
|
|
||||||
|
return i->last_request;
|
||||||
|
}
|
||||||
|
|
||||||
void piece_picker::get_availability(std::vector<int>& avail) const
|
void piece_picker::get_availability(std::vector<int>& avail) const
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_seeds >= 0);
|
TORRENT_ASSERT(m_seeds >= 0);
|
||||||
|
|
|
@ -264,7 +264,13 @@ namespace libtorrent
|
||||||
num_requests--;
|
num_requests--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (busy_pieces.empty() || num_requests <= 0)
|
// if we don't have any potential busy blocks to request
|
||||||
|
// or if we have picked as many blocks as we should
|
||||||
|
// or if we already have outstanding requests, don't
|
||||||
|
// pick a busy piece
|
||||||
|
if (busy_pieces.empty()
|
||||||
|
|| num_requests <= 0
|
||||||
|
|| dq.size() + rq.size() > 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -285,6 +291,15 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
TORRENT_ASSERT(p.is_requested(*i));
|
TORRENT_ASSERT(p.is_requested(*i));
|
||||||
TORRENT_ASSERT(p.num_peers(*i) > 0);
|
TORRENT_ASSERT(p.num_peers(*i) > 0);
|
||||||
|
|
||||||
|
ptime last_request = p.last_request(i->piece_index);
|
||||||
|
ptime now = time_now();
|
||||||
|
|
||||||
|
// don't re-request from a piece more often than once every 20 seconds
|
||||||
|
// TODO: make configurable
|
||||||
|
if (now - last_request < seconds(20))
|
||||||
|
return;
|
||||||
|
|
||||||
c.add_request(*i, peer_connection::req_busy);
|
c.add_request(*i, peer_connection::req_busy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue