some refactor and cleanup (#1065)
This commit is contained in:
parent
994a84cfe8
commit
b313de3925
|
@ -33,13 +33,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_ALLOCATING_HANDLER_HPP_INCLUDED
|
#ifndef TORRENT_ALLOCATING_HANDLER_HPP_INCLUDED
|
||||||
#define TORRENT_ALLOCATING_HANDLER_HPP_INCLUDED
|
#define TORRENT_ALLOCATING_HANDLER_HPP_INCLUDED
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#include <boost/aligned_storage.hpp>
|
#include <boost/aligned_storage.hpp>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
namespace libtorrent { namespace aux
|
namespace libtorrent { namespace aux
|
||||||
|
@ -125,4 +122,3 @@ namespace libtorrent { namespace aux
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_BANDWIDTH_MANAGER_HPP_INCLUDED
|
#define TORRENT_BANDWIDTH_MANAGER_HPP_INCLUDED
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "libtorrent/socket.hpp"
|
|
||||||
#include "libtorrent/error_code.hpp"
|
|
||||||
#include "libtorrent/invariant_check.hpp"
|
#include "libtorrent/invariant_check.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/bandwidth_limit.hpp"
|
#include "libtorrent/bandwidth_limit.hpp"
|
||||||
|
@ -76,8 +75,7 @@ struct TORRENT_EXTRA_EXPORT bandwidth_manager
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// these are the consumers that want bandwidth
|
// these are the consumers that want bandwidth
|
||||||
typedef std::vector<bw_request> queue_t;
|
std::vector<bw_request> m_queue;
|
||||||
queue_t m_queue;
|
|
||||||
// the number of bytes all the requests in queue are for
|
// the number of bytes all the requests in queue are for
|
||||||
std::int64_t m_queued_bytes;
|
std::int64_t m_queued_bytes;
|
||||||
|
|
||||||
|
@ -91,4 +89,3 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct TORRENT_EXTRA_EXPORT bw_request
|
||||||
// from the most limiting one
|
// from the most limiting one
|
||||||
int assign_bandwidth();
|
int assign_bandwidth();
|
||||||
|
|
||||||
enum { max_bandwidth_channels = 10 };
|
constexpr static int max_bandwidth_channels = 10;
|
||||||
// we don't actually support more than 10 channels per peer
|
// we don't actually support more than 10 channels per peer
|
||||||
bandwidth_channel* channel[max_bandwidth_channels];
|
bandwidth_channel* channel[max_bandwidth_channels];
|
||||||
};
|
};
|
||||||
|
@ -71,4 +71,3 @@ struct TORRENT_EXTRA_EXPORT bw_request
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef TORRENT_BANDWIDTH_SOCKET_HPP_INCLUDED
|
#ifndef TORRENT_BANDWIDTH_SOCKET_HPP_INCLUDED
|
||||||
#define TORRENT_BANDWIDTH_SOCKET_HPP_INCLUDED
|
#define TORRENT_BANDWIDTH_SOCKET_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "libtorrent/export.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
struct TORRENT_EXTRA_EXPORT bandwidth_socket
|
struct TORRENT_EXTRA_EXPORT bandwidth_socket
|
||||||
|
@ -45,4 +46,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TORRENT_BANDWIDTH_SOCKET_HPP_INCLUDED
|
#endif // TORRENT_BANDWIDTH_SOCKET_HPP_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void reclaim_block(block_cache_reference const& ref);
|
void reclaim_block(block_cache_reference const& ref);
|
||||||
|
|
||||||
// returns a range of all pieces. This migh be a very
|
// returns a range of all pieces. This might be a very
|
||||||
// long list, use carefully
|
// long list, use carefully
|
||||||
std::pair<iterator, iterator> all_pieces() const;
|
std::pair<iterator, iterator> all_pieces() const;
|
||||||
int num_pieces() const { return int(m_pieces.size()); }
|
int num_pieces() const { return int(m_pieces.size()); }
|
||||||
|
@ -536,7 +536,7 @@ namespace libtorrent
|
||||||
int m_pinned_blocks;
|
int m_pinned_blocks;
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
std::vector<std::pair<std::string, void const*> > m_deleted_storages;
|
std::vector<std::pair<std::string, void const*>> m_deleted_storages;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/peer_id.hpp"
|
#include "libtorrent/peer_id.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
|
||||||
#include "libtorrent/address.hpp"
|
#include "libtorrent/address.hpp"
|
||||||
|
|
||||||
namespace libtorrent { namespace dht
|
namespace libtorrent { namespace dht
|
||||||
|
@ -77,4 +76,3 @@ node_id TORRENT_EXTRA_EXPORT generate_prefix_mask(int bits);
|
||||||
} } // namespace libtorrent::dht
|
} } // namespace libtorrent::dht
|
||||||
|
|
||||||
#endif // NODE_ID_HPP
|
#endif // NODE_ID_HPP
|
||||||
|
|
||||||
|
|
|
@ -93,4 +93,3 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1306,4 +1306,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TORRENT_TORRENT_HANDLE_HPP_INCLUDED
|
#endif // TORRENT_TORRENT_HANDLE_HPP_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libtorrent/bandwidth_manager.hpp"
|
#include "libtorrent/bandwidth_manager.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
|
||||||
|
#if TORRENT_USE_ASSERTS
|
||||||
|
#include <climits>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -47,7 +50,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
|
|
||||||
queue_t tm;
|
std::vector<bw_request> tm;
|
||||||
tm.swap(m_queue);
|
tm.swap(m_queue);
|
||||||
m_queued_bytes = 0;
|
m_queued_bytes = 0;
|
||||||
|
|
||||||
|
@ -62,10 +65,9 @@ namespace libtorrent
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
bool bandwidth_manager::is_queued(bandwidth_socket const* peer) const
|
bool bandwidth_manager::is_queued(bandwidth_socket const* peer) const
|
||||||
{
|
{
|
||||||
for (queue_t::const_iterator i = m_queue.begin()
|
for (auto const& r : m_queue)
|
||||||
, end(m_queue.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if (i->peer.get() == peer) return true;
|
if (r.peer.get() == peer) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -125,10 +127,9 @@ namespace libtorrent
|
||||||
void bandwidth_manager::check_invariant() const
|
void bandwidth_manager::check_invariant() const
|
||||||
{
|
{
|
||||||
std::int64_t queued = 0;
|
std::int64_t queued = 0;
|
||||||
for (queue_t::const_iterator i = m_queue.begin()
|
for (auto const& r : m_queue)
|
||||||
, end(m_queue.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
queued += i->request_size - i->assigned;
|
queued += r.request_size - r.assigned;
|
||||||
}
|
}
|
||||||
TORRENT_ASSERT(queued == m_queued_bytes);
|
TORRENT_ASSERT(queued == m_queued_bytes);
|
||||||
}
|
}
|
||||||
|
@ -148,10 +149,9 @@ namespace libtorrent
|
||||||
|
|
||||||
std::vector<bandwidth_channel*> channels;
|
std::vector<bandwidth_channel*> channels;
|
||||||
|
|
||||||
queue_t tm;
|
std::vector<bw_request> tm;
|
||||||
|
|
||||||
for (queue_t::iterator i = m_queue.begin();
|
for (auto i = m_queue.begin(); i != m_queue.end();)
|
||||||
i != m_queue.end();)
|
|
||||||
{
|
{
|
||||||
if (i->peer->is_disconnecting())
|
if (i->peer->is_disconnecting())
|
||||||
{
|
{
|
||||||
|
@ -178,26 +178,23 @@ namespace libtorrent
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (queue_t::iterator i = m_queue.begin()
|
for (auto const& r : m_queue)
|
||||||
, end(m_queue.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
for (int j = 0; j < bw_request::max_bandwidth_channels && i->channel[j]; ++j)
|
for (int j = 0; j < bw_request::max_bandwidth_channels && r.channel[j]; ++j)
|
||||||
{
|
{
|
||||||
bandwidth_channel* bwc = i->channel[j];
|
bandwidth_channel* bwc = r.channel[j];
|
||||||
if (bwc->tmp == 0) channels.push_back(bwc);
|
if (bwc->tmp == 0) channels.push_back(bwc);
|
||||||
TORRENT_ASSERT(INT_MAX - bwc->tmp > i->priority);
|
TORRENT_ASSERT(INT_MAX - bwc->tmp > r.priority);
|
||||||
bwc->tmp += i->priority;
|
bwc->tmp += r.priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<bandwidth_channel*>::iterator i = channels.begin()
|
for (auto const& ch : channels)
|
||||||
, end(channels.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
(*i)->update_quota(int(dt_milliseconds));
|
ch->update_quota(int(dt_milliseconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (queue_t::iterator i = m_queue.begin();
|
for (auto i = m_queue.begin(); i != m_queue.end();)
|
||||||
i != m_queue.end();)
|
|
||||||
{
|
{
|
||||||
int a = i->assign_bandwidth();
|
int a = i->assign_bandwidth();
|
||||||
if (i->assigned == i->request_size
|
if (i->assigned == i->request_size
|
||||||
|
@ -223,4 +220,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1222,10 +1222,9 @@ void block_cache::clear(tailqueue<disk_io_job>& jobs)
|
||||||
// at the end
|
// at the end
|
||||||
std::vector<char*> bufs;
|
std::vector<char*> bufs;
|
||||||
|
|
||||||
for (iterator p = m_pieces.begin()
|
for (auto const& p : m_pieces)
|
||||||
, end(m_pieces.end()); p != end; ++p)
|
|
||||||
{
|
{
|
||||||
cached_piece_entry& pe = const_cast<cached_piece_entry&>(*p);
|
cached_piece_entry& pe = const_cast<cached_piece_entry&>(p);
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
for (tailqueue_iterator<disk_io_job> i = pe.jobs.iterate(); i.get(); i.next())
|
for (tailqueue_iterator<disk_io_job> i = pe.jobs.iterate(); i.get(); i.next())
|
||||||
TORRENT_PIECE_ASSERT((static_cast<disk_io_job const*>(i.get()))->piece == pe.piece, &pe);
|
TORRENT_PIECE_ASSERT((static_cast<disk_io_job const*>(i.get()))->piece == pe.piece, &pe);
|
||||||
|
@ -1664,9 +1663,8 @@ void block_cache::check_invariant() const
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unordered_set<char*> buffers;
|
boost::unordered_set<char*> buffers;
|
||||||
for (iterator i = m_pieces.begin(), end(m_pieces.end()); i != end; ++i)
|
for (auto const& p :m_pieces)
|
||||||
{
|
{
|
||||||
cached_piece_entry const& p = *i;
|
|
||||||
TORRENT_PIECE_ASSERT(p.blocks, &p);
|
TORRENT_PIECE_ASSERT(p.blocks, &p);
|
||||||
|
|
||||||
TORRENT_PIECE_ASSERT(p.storage, &p);
|
TORRENT_PIECE_ASSERT(p.storage, &p);
|
||||||
|
@ -1887,7 +1885,7 @@ cached_piece_entry* block_cache::find_piece(piece_manager* st, int piece)
|
||||||
cached_piece_entry model;
|
cached_piece_entry model;
|
||||||
model.storage = st->shared_from_this();
|
model.storage = st->shared_from_this();
|
||||||
model.piece = piece;
|
model.piece = piece;
|
||||||
iterator i = m_pieces.find(model);
|
auto i = m_pieces.find(model);
|
||||||
TORRENT_ASSERT(i == m_pieces.end() || (i->storage.get() == st && i->piece == piece));
|
TORRENT_ASSERT(i == m_pieces.end() || (i->storage.get() == st && i->piece == piece));
|
||||||
if (i == m_pieces.end()) return nullptr;
|
if (i == m_pieces.end()) return nullptr;
|
||||||
TORRENT_PIECE_ASSERT(i->in_use, &*i);
|
TORRENT_PIECE_ASSERT(i->in_use, &*i);
|
||||||
|
@ -1904,4 +1902,3 @@ cached_piece_entry* block_cache::find_piece(piece_manager* st, int piece)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,8 +180,7 @@ namespace libtorrent
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
// by now, all pieces should have been evicted
|
// by now, all pieces should have been evicted
|
||||||
std::pair<block_cache::iterator, block_cache::iterator> pieces
|
auto pieces = m_disk_cache.all_pieces();
|
||||||
= m_disk_cache.all_pieces();
|
|
||||||
TORRENT_ASSERT(pieces.first == pieces.second);
|
TORRENT_ASSERT(pieces.first == pieces.second);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -837,7 +836,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::pair<block_cache::iterator, block_cache::iterator> range = m_disk_cache.all_pieces();
|
auto range = m_disk_cache.all_pieces();
|
||||||
while (range.first != range.second)
|
while (range.first != range.second)
|
||||||
{
|
{
|
||||||
// TODO: it would be nice to optimize this by having the cache
|
// TODO: it would be nice to optimize this by having the cache
|
||||||
|
@ -1635,8 +1634,8 @@ namespace libtorrent
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
#if TORRENT_USE_ASSERTS && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||||
std::unique_lock<std::mutex> l2_(m_cache_mutex);
|
std::unique_lock<std::mutex> l2_(m_cache_mutex);
|
||||||
std::pair<block_cache::iterator, block_cache::iterator> range = m_disk_cache.all_pieces();
|
auto range = m_disk_cache.all_pieces();
|
||||||
for (block_cache::iterator i = range.first; i != range.second; ++i)
|
for (auto i = range.first; i != range.second; ++i)
|
||||||
{
|
{
|
||||||
cached_piece_entry const& p = *i;
|
cached_piece_entry const& p = *i;
|
||||||
int bs = m_disk_cache.block_size();
|
int bs = m_disk_cache.block_size();
|
||||||
|
@ -2784,10 +2783,8 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
ret->pieces.reserve(m_disk_cache.num_pieces());
|
ret->pieces.reserve(m_disk_cache.num_pieces());
|
||||||
|
|
||||||
std::pair<block_cache::iterator, block_cache::iterator> range
|
auto range = m_disk_cache.all_pieces();
|
||||||
= m_disk_cache.all_pieces();
|
for (auto i = range.first; i != range.second; ++i)
|
||||||
|
|
||||||
for (block_cache::iterator i = range.first; i != range.second; ++i)
|
|
||||||
{
|
{
|
||||||
if (i->cache_state == cached_piece_entry::read_lru2_ghost
|
if (i->cache_state == cached_piece_entry::read_lru2_ghost
|
||||||
|| i->cache_state == cached_piece_entry::read_lru1_ghost)
|
|| i->cache_state == cached_piece_entry::read_lru1_ghost)
|
||||||
|
@ -3308,8 +3305,7 @@ namespace libtorrent
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
// by now, all pieces should have been evicted
|
// by now, all pieces should have been evicted
|
||||||
std::pair<block_cache::iterator, block_cache::iterator> pieces
|
auto pieces = m_disk_cache.all_pieces();
|
||||||
= m_disk_cache.all_pieces();
|
|
||||||
TORRENT_ASSERT(pieces.first == pieces.second);
|
TORRENT_ASSERT(pieces.first == pieces.second);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/kademlia/node_entry.hpp"
|
#include "libtorrent/kademlia/node_entry.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/broadcast_socket.hpp" // for is_local et.al
|
#include "libtorrent/broadcast_socket.hpp" // for is_local et.al
|
||||||
#include "libtorrent/socket_io.hpp" // for hash_address
|
|
||||||
#include "libtorrent/random.hpp" // for random
|
#include "libtorrent/random.hpp" // for random
|
||||||
#include "libtorrent/hasher.hpp" // for hasher
|
#include "libtorrent/hasher.hpp" // for hasher
|
||||||
#include "libtorrent/crc32c.hpp" // for crc32c
|
#include "libtorrent/crc32c.hpp" // for crc32c
|
||||||
|
@ -153,13 +152,14 @@ void make_id_secret(node_id& in)
|
||||||
hasher h(reinterpret_cast<char const*>(&secret), 4);
|
hasher h(reinterpret_cast<char const*>(&secret), 4);
|
||||||
h.update(reinterpret_cast<char const*>(&rand), 4);
|
h.update(reinterpret_cast<char const*>(&rand), 4);
|
||||||
sha1_hash const secret_hash = h.final();
|
sha1_hash const secret_hash = h.final();
|
||||||
memcpy(&in[20-4], &secret_hash[0], 4);
|
std::memcpy(&in[20 - 4], &secret_hash[0], 4);
|
||||||
memcpy(&in[20-8], &rand, 4);
|
std::memcpy(&in[20 - 8], &rand, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
node_id generate_random_id()
|
node_id generate_random_id()
|
||||||
{
|
{
|
||||||
char r[20];
|
char r[20];
|
||||||
|
// TODO: use here aux::random_bytes?
|
||||||
for (int i = 0; i < 20; ++i) r[i] = random(0xff);
|
for (int i = 0; i < 20; ++i) r[i] = random(0xff);
|
||||||
return hasher(r, 20).final();
|
return hasher(r, 20).final();
|
||||||
}
|
}
|
||||||
|
@ -176,9 +176,9 @@ bool verify_secret_id(node_id const& nid)
|
||||||
if (secret == 0) return false;
|
if (secret == 0) return false;
|
||||||
|
|
||||||
hasher h(reinterpret_cast<char*>(&secret), 4);
|
hasher h(reinterpret_cast<char*>(&secret), 4);
|
||||||
h.update(reinterpret_cast<char const*>(&nid[20-8]), 4);
|
h.update(reinterpret_cast<char const*>(&nid[20 - 8]), 4);
|
||||||
sha1_hash secret_hash = h.final();
|
sha1_hash secret_hash = h.final();
|
||||||
return memcmp(&nid[20-4], &secret_hash[0], 4) == 0;
|
return std::memcmp(&nid[20 - 4], &secret_hash[0], 4) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifies whether a node-id matches the IP it's used from
|
// verifies whether a node-id matches the IP it's used from
|
||||||
|
@ -211,10 +211,9 @@ node_id generate_prefix_mask(int bits)
|
||||||
TORRENT_ASSERT(bits <= 160);
|
TORRENT_ASSERT(bits <= 160);
|
||||||
node_id mask(nullptr);
|
node_id mask(nullptr);
|
||||||
int b = 0;
|
int b = 0;
|
||||||
for (; b < bits - 7; b += 8) mask[b/8] |= 0xff;
|
for (; b < bits - 7; b += 8) mask[b / 8] |= 0xff;
|
||||||
if (bits < 160) mask[b/8] |= (0xff << (8 - (bits&7))) & 0xff;
|
if (bits < 160) mask[b / 8] |= (0xff << (8 - (bits & 7))) & 0xff;
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
} } // namespace libtorrent::dht
|
} } // namespace libtorrent::dht
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ resolve_links::resolve_links(std::shared_ptr<torrent_info> ti)
|
||||||
for (int i = 0; i < fs.num_files(); ++i)
|
for (int i = 0; i < fs.num_files(); ++i)
|
||||||
{
|
{
|
||||||
// don't match pad-files, and don't match files that aren't aligned to
|
// don't match pad-files, and don't match files that aren't aligned to
|
||||||
// ieces. Files are matched by comparing piece hashes, so pieces must
|
// pieces. Files are matched by comparing piece hashes, so pieces must
|
||||||
// be aligned and the same size
|
// be aligned and the same size
|
||||||
if (fs.pad_file_at(i)) continue;
|
if (fs.pad_file_at(i)) continue;
|
||||||
if ((fs.file_offset(i) % piece_size) != 0) continue;
|
if ((fs.file_offset(i) % piece_size) != 0) continue;
|
||||||
|
@ -84,8 +84,7 @@ void resolve_links::match(std::shared_ptr<const torrent_info> const& ti
|
||||||
|
|
||||||
std::int64_t file_size = fs.file_size(i);
|
std::int64_t file_size = fs.file_size(i);
|
||||||
|
|
||||||
typedef boost::unordered_multimap<std::int64_t, int>::iterator iterator;
|
auto iter = m_file_sizes.find(file_size);
|
||||||
iterator iter = m_file_sizes.find(file_size);
|
|
||||||
|
|
||||||
// we don't have a file whose size matches, look at the next one
|
// we don't have a file whose size matches, look at the next one
|
||||||
if (iter == m_file_sizes.end()) continue;
|
if (iter == m_file_sizes.end()) continue;
|
||||||
|
|
|
@ -4590,7 +4590,7 @@ namespace aux {
|
||||||
add_torrent_params params = p;
|
add_torrent_params params = p;
|
||||||
std::shared_ptr<torrent> torrent_ptr;
|
std::shared_ptr<torrent> torrent_ptr;
|
||||||
bool added;
|
bool added;
|
||||||
boost::tie(torrent_ptr, added) = add_torrent_impl(params, ec);
|
std::tie(torrent_ptr, added) = add_torrent_impl(params, ec);
|
||||||
|
|
||||||
torrent_handle const handle(torrent_ptr);
|
torrent_handle const handle(torrent_ptr);
|
||||||
m_alerts.emplace_alert<add_torrent_alert>(handle, params, ec);
|
m_alerts.emplace_alert<add_torrent_alert>(handle, params, ec);
|
||||||
|
|
|
@ -740,4 +740,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio> // for snprintf
|
#include <cstdio> // for snprintf
|
||||||
|
@ -61,10 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
enum
|
constexpr int request_size_overhead = 5000;
|
||||||
{
|
|
||||||
request_size_overhead = 5000
|
|
||||||
};
|
|
||||||
|
|
||||||
struct disk_interface;
|
struct disk_interface;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue