not add peers from url if add_torrent_impl returns invalid handle (#814)
This commit is contained in:
parent
96ea0dc4d0
commit
d759d8f742
|
@ -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);
|
||||
|
|
|
@ -884,7 +884,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;
|
||||
|
||||
|
|
|
@ -4785,6 +4785,14 @@ retry:
|
|||
add_torrent_params params = p;
|
||||
boost::shared_ptr<torrent> const torrent_ptr = add_torrent_impl(params, ec);
|
||||
|
||||
torrent_handle const handle(torrent_ptr);
|
||||
m_alerts.emplace_alert<add_torrent_alert>(handle, params, ec);
|
||||
|
||||
if (!torrent_ptr) return handle;
|
||||
|
||||
// params.info_hash should have been initialized by add_torrent_impl()
|
||||
TORRENT_ASSERT(params.info_hash != sha1_hash(0));
|
||||
|
||||
// --- PEERS --- (delete when merged to master)
|
||||
std::vector<tcp::endpoint> peers;
|
||||
parse_magnet_uri_peers(p.url, peers);
|
||||
|
@ -4798,14 +4806,6 @@ retry:
|
|||
if (!peers.empty())
|
||||
torrent_ptr->update_want_peers();
|
||||
|
||||
torrent_handle const handle(torrent_ptr);
|
||||
m_alerts.emplace_alert<add_torrent_alert>(handle, params, ec);
|
||||
|
||||
if (!torrent_ptr) return handle;
|
||||
|
||||
// params.info_hash should have been initialized by add_torrent_impl()
|
||||
TORRENT_ASSERT(params.info_hash != sha1_hash(0));
|
||||
|
||||
if (m_alerts.should_post<torrent_added_alert>())
|
||||
m_alerts.emplace_alert<torrent_added_alert>(handle);
|
||||
|
||||
|
@ -6405,7 +6405,7 @@ retry:
|
|||
|
||||
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;
|
||||
|
|
|
@ -2001,7 +2001,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()))
|
||||
{
|
||||
|
@ -3875,10 +3875,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)
|
||||
|
@ -3886,7 +3886,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;
|
||||
}
|
||||
|
||||
|
@ -8631,7 +8631,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;
|
||||
|
@ -8832,7 +8832,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < m_torrent_file->num_files());
|
||||
|
||||
// stoage may be NULL during shutdown
|
||||
// storage may be NULL during shutdown
|
||||
if (!m_storage.get())
|
||||
{
|
||||
if (alerts().should_post<file_rename_failed_alert>())
|
||||
|
|
Loading…
Reference in New Issue