forked from premiere/premiere-libtorrent
fix merge
This commit is contained in:
commit
4b186130e6
|
@ -21,6 +21,9 @@
|
|||
|
||||
1.1.1 release
|
||||
|
||||
* fix bug in python binding of announce_entry
|
||||
* fixed bug related to flag_merge_resume_http_seeds flag in add_torrent_params
|
||||
* fixed inverted priority of incoming piece suggestions
|
||||
* optimize allow-fast logic
|
||||
* fix issue where FAST extension messages were not used during handshake
|
||||
* fixed crash on invalid input in http_parser
|
||||
|
|
|
@ -193,9 +193,9 @@ void dict_to_announce_entry(dict d, announce_entry& ae)
|
|||
if (d.has_key("source"))
|
||||
ae.source = extract<int>(d["source"]);
|
||||
if (d.has_key("verified"))
|
||||
ae.verified = extract<int>(d["verified"]);
|
||||
ae.verified = extract<bool>(d["verified"]);
|
||||
if (d.has_key("send_stats"))
|
||||
ae.send_stats = extract<int>(d["send_stats"]);
|
||||
ae.send_stats = extract<bool>(d["send_stats"]);
|
||||
}
|
||||
|
||||
void replace_trackers(torrent_handle& h, object trackers)
|
||||
|
|
|
@ -113,10 +113,10 @@ namespace
|
|||
|
||||
int get_tier(announce_entry const& ae) { return ae.tier; }
|
||||
void set_tier(announce_entry& ae, int v) { ae.tier = v; }
|
||||
bool get_fail_limit(announce_entry const& ae) { return ae.fail_limit; }
|
||||
int get_fail_limit(announce_entry const& ae) { return ae.fail_limit; }
|
||||
void set_fail_limit(announce_entry& ae, int l) { ae.fail_limit = l; }
|
||||
bool get_fails(announce_entry const& ae) { return ae.fails; }
|
||||
bool get_source(announce_entry const& ae) { return ae.source; }
|
||||
int get_fails(announce_entry const& ae) { return ae.fails; }
|
||||
int get_source(announce_entry const& ae) { return ae.source; }
|
||||
bool get_verified(announce_entry const& ae) { return ae.verified; }
|
||||
bool get_updating(announce_entry const& ae) { return ae.updating; }
|
||||
bool get_start_sent(announce_entry const& ae) { return ae.start_sent; }
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace libtorrent { namespace aux
|
|||
};
|
||||
#endif // TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
|
||||
|
||||
// TOOD: 2 make this interface a lot smaller. It could be split up into
|
||||
// TODO: 2 make this interface a lot smaller. It could be split up into
|
||||
// several smaller interfaces. Each subsystem could then limit the size
|
||||
// of the mock object to test it.
|
||||
struct TORRENT_EXTRA_EXPORT session_interface
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace libtorrent
|
|||
public:
|
||||
|
||||
// this is the constructor where the we are the active part.
|
||||
// The peer_conenction should handshake and verify that the
|
||||
// The peer_connection should handshake and verify that the
|
||||
// other end has the correct id
|
||||
bt_peer_connection(peer_connection_args const& pack
|
||||
, peer_id const& pid);
|
||||
|
|
|
@ -862,7 +862,7 @@ namespace libtorrent
|
|||
void on_inactivity_tick(error_code const& ec);
|
||||
|
||||
|
||||
// calculate the instantaneuos inactive state (the externally facing
|
||||
// calculate the instantaneous inactive state (the externally facing
|
||||
// inactive state is not instantaneous, but low-pass filtered)
|
||||
bool is_inactive_internal() const;
|
||||
|
||||
|
|
|
@ -1574,10 +1574,14 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
// the piece picker will prioritize the pieces from the beginning to end.
|
||||
// the later the suggestion is received, the higher priority we should
|
||||
// ascribe to it, so we need to insert suggestions at the front of the
|
||||
// queue.
|
||||
if (int(m_suggested_pieces.size()) > m_settings.get_int(settings_pack::max_suggest_pieces))
|
||||
m_suggested_pieces.erase(m_suggested_pieces.begin());
|
||||
m_suggested_pieces.resize(m_settings.get_int(settings_pack::max_suggest_pieces) - 1);
|
||||
|
||||
m_suggested_pieces.push_back(index);
|
||||
m_suggested_pieces.insert(m_suggested_pieces.begin(), index);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::info, "SUGGEST_PIECE", "piece: %d added to set: %d"
|
||||
|
|
|
@ -1309,7 +1309,7 @@ namespace aux {
|
|||
|
||||
int loaded_limit = m_settings.get_int(settings_pack::active_loaded_limit);
|
||||
|
||||
// 0 means unlimited, never evict enything
|
||||
// 0 means unlimited, never evict anything
|
||||
if (loaded_limit == 0) return;
|
||||
|
||||
if (m_torrent_lru.size() > loaded_limit)
|
||||
|
@ -1333,7 +1333,7 @@ namespace aux {
|
|||
|
||||
int loaded_limit = m_settings.get_int(settings_pack::active_loaded_limit);
|
||||
|
||||
// 0 means unlimited, never evict enything
|
||||
// 0 means unlimited, never evict anything
|
||||
if (loaded_limit == 0) return;
|
||||
|
||||
// if the torrent we're ignoring (i.e. making room for), allow
|
||||
|
@ -1374,6 +1374,7 @@ namespace aux {
|
|||
// we wouldn't be loading the torrent if it was already
|
||||
// in the LRU (and loaded)
|
||||
TORRENT_ASSERT(t->next == NULL && t->prev == NULL && m_torrent_lru.front() != t);
|
||||
TORRENT_ASSERT(m_user_load_torrent);
|
||||
|
||||
// now, load t into RAM
|
||||
std::vector<char> buffer;
|
||||
|
@ -6007,7 +6008,7 @@ namespace aux {
|
|||
|
||||
void session_impl::update_user_agent()
|
||||
{
|
||||
// replace all occurances of '\n' with ' '.
|
||||
// replace all occurrences of '\n' with ' '.
|
||||
std::string agent = m_settings.get_str(settings_pack::user_agent);
|
||||
std::string::iterator i = agent.begin();
|
||||
while ((i = std::find(i, agent.end(), '\n'))
|
||||
|
@ -6129,7 +6130,7 @@ namespace aux {
|
|||
|
||||
void session_impl::on_trigger_auto_manage()
|
||||
{
|
||||
assert(m_pending_auto_manage);
|
||||
TORRENT_ASSERT(m_pending_auto_manage);
|
||||
if (!m_need_auto_manage || m_abort)
|
||||
{
|
||||
m_pending_auto_manage = false;
|
||||
|
|
|
@ -1873,7 +1873,7 @@ namespace libtorrent
|
|||
}
|
||||
// ugly edge case where padfiles are not used they way they're
|
||||
// supposed to be. i.e. added back-to back or at the end
|
||||
if (int(pb.block_index) == blocks_per_piece) { pb.block_index = 0; ++pb.piece_index; }
|
||||
if (pb.block_index == blocks_per_piece) { pb.block_index = 0; ++pb.piece_index; }
|
||||
if (pr.length > 0 && ((i+1 != fs.num_files() && fs.pad_file_at(i+1))
|
||||
|| i + 1 == fs.num_files()))
|
||||
{
|
||||
|
@ -3656,10 +3656,10 @@ namespace libtorrent
|
|||
file_storage const& fs = m_torrent_file->files();
|
||||
int piece_size = m_torrent_file->piece_size(p.piece_index);
|
||||
int offset = p.block_index * block_size();
|
||||
if (m_padding == 0) return (std::min)(piece_size - offset, int(block_size()));
|
||||
if (m_padding == 0) return (std::min)(piece_size - offset, block_size());
|
||||
|
||||
std::vector<file_slice> files = fs.map_block(
|
||||
p.piece_index, offset, (std::min)(piece_size - offset, int(block_size())));
|
||||
p.piece_index, offset, (std::min)(piece_size - offset, block_size()));
|
||||
int ret = 0;
|
||||
for (std::vector<file_slice>::iterator i = files.begin()
|
||||
, end(files.end()); i != end; ++i)
|
||||
|
@ -3667,7 +3667,7 @@ namespace libtorrent
|
|||
if (fs.pad_file_at(i->file_index)) continue;
|
||||
ret += i->size;
|
||||
}
|
||||
TORRENT_ASSERT(ret <= (std::min)(piece_size - offset, int(block_size())));
|
||||
TORRENT_ASSERT(ret <= (std::min)(piece_size - offset, block_size()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -7914,7 +7914,7 @@ namespace libtorrent
|
|||
|
||||
// this will move the tracker with the given index
|
||||
// to a prioritized position in the list (move it towards
|
||||
// the begining) and return the new index to the tracker.
|
||||
// the beginning) and return the new index to the tracker.
|
||||
int torrent::prioritize_tracker(int index)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
|
|
@ -623,7 +623,7 @@ TORRENT_TEST(reject_suggest)
|
|||
|
||||
using namespace libtorrent::detail;
|
||||
char* ptr = recv_buffer + 1;
|
||||
int piece = read_int32(ptr);
|
||||
int const piece = read_int32(ptr);
|
||||
|
||||
std::vector<int>::iterator i = std::find(suggested.begin()
|
||||
, suggested.end(), piece);
|
||||
|
@ -657,6 +657,66 @@ TORRENT_TEST(reject_suggest)
|
|||
print_session_log(*ses);
|
||||
}
|
||||
|
||||
TORRENT_TEST(suggest_order)
|
||||
{
|
||||
std::cerr << "\n === test suggest ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
boost::shared_ptr<lt::session> ses;
|
||||
io_service ios;
|
||||
tcp::socket s(ios);
|
||||
setup_peer(s, ih, ses);
|
||||
|
||||
char recv_buffer[1000];
|
||||
do_handshake(s, ih, recv_buffer);
|
||||
print_session_log(*ses);
|
||||
send_have_all(s);
|
||||
print_session_log(*ses);
|
||||
|
||||
std::vector<int> suggested;
|
||||
suggested.push_back(0);
|
||||
suggested.push_back(1);
|
||||
suggested.push_back(2);
|
||||
suggested.push_back(3);
|
||||
|
||||
std::for_each(suggested.begin(), suggested.end()
|
||||
, boost::bind(&send_suggest_piece, boost::ref(s), _1));
|
||||
print_session_log(*ses);
|
||||
|
||||
send_unchoke(s);
|
||||
print_session_log(*ses);
|
||||
|
||||
int fail_counter = 100;
|
||||
while (!suggested.empty() && fail_counter > 0)
|
||||
{
|
||||
print_session_log(*ses);
|
||||
int len = read_message(s, recv_buffer, sizeof(recv_buffer));
|
||||
if (len == -1) break;
|
||||
print_message(recv_buffer, len);
|
||||
int msg = recv_buffer[0];
|
||||
fail_counter--;
|
||||
|
||||
// we're just interested in requests
|
||||
if (msg != 0x6) continue;
|
||||
|
||||
using namespace libtorrent::detail;
|
||||
char* ptr = recv_buffer + 1;
|
||||
int const piece = read_int32(ptr);
|
||||
|
||||
// make sure we receive the requests inverse order of sending the suggest
|
||||
// messages. The last suggest should be the highest priority
|
||||
int const expected_piece = suggested.back();
|
||||
suggested.pop_back();
|
||||
TEST_EQUAL(piece, expected_piece);
|
||||
}
|
||||
print_session_log(*ses);
|
||||
TEST_CHECK(fail_counter > 0);
|
||||
|
||||
s.close();
|
||||
test_sleep(500);
|
||||
print_session_log(*ses);
|
||||
}
|
||||
|
||||
TORRENT_TEST(multiple_bitfields)
|
||||
{
|
||||
std::cerr << "\n === test multiple bitfields ===\n" << std::endl;
|
||||
|
|
Loading…
Reference in New Issue