Merge pull request #276 from arvidn/msvc-warnings

attempt to fix some msvc warnings
This commit is contained in:
Arvid Norberg 2015-11-20 08:04:38 -05:00
commit 2eabf99307
39 changed files with 169 additions and 122 deletions

View File

@ -26,8 +26,12 @@
#include "gil.hpp"
#include "bytes.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/python.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
using namespace boost::python;
using namespace libtorrent;
namespace lt = libtorrent;

View File

@ -2,8 +2,13 @@
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/python.hpp>
#include <boost/shared_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/session_settings.hpp"
#include "libtorrent/time.hpp"

View File

@ -260,7 +260,7 @@ namespace libtorrent
std::string const& collection) const TORRENT_OVERRIDE TORRENT_FINAL;
#endif
boost::weak_ptr<torrent> find_disconnect_candidate_torrent() const TORRENT_OVERRIDE TORRENT_FINAL;
int num_torrents() const TORRENT_OVERRIDE TORRENT_FINAL { return m_torrents.size(); }
int num_torrents() const TORRENT_OVERRIDE TORRENT_FINAL { return int(m_torrents.size()); }
void insert_torrent(sha1_hash const& ih, boost::shared_ptr<torrent> const& t
, std::string uuid);
@ -458,8 +458,7 @@ namespace libtorrent
bool preemptive_unchoke() const;
int num_uploads() const
{ return int(m_stats_counters[counters::num_peers_up_unchoked]); }
int num_connections() const
{ return m_connections.size(); }
int num_connections() const { return int(m_connections.size()); }
int peak_up_rate() const { return m_peak_up_rate; }

View File

@ -107,7 +107,7 @@ namespace libtorrent { namespace aux
// This is the basic logging and debug interface offered by the session.
// a release build with logging disabled (which is the default) will
// not have this class at all
struct session_logger
struct TORRENT_EXTRA_EXPORT session_logger
{
#ifndef TORRENT_DISABLE_LOGGING
virtual void session_log(char const* fmt, ...) const TORRENT_FORMAT(2,3) = 0;
@ -128,7 +128,7 @@ namespace libtorrent { namespace aux
// TOOD: 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 session_interface
struct TORRENT_EXTRA_EXPORT session_interface
: buffer_allocator_interface
#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, session_logger

View File

@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct bandwidth_socket
struct TORRENT_EXTRA_EXPORT bandwidth_socket
{
virtual void assign_bandwidth(int channel, int amount) = 0;
virtual bool is_disconnecting() const = 0;

View File

@ -94,7 +94,7 @@ namespace libtorrent
#ifndef TORRENT_NO_DEPRECATE
// thrown by bdecode() if the provided bencoded buffer does not contain
// valid encoding.
struct TORRENT_EXPORT invalid_encoding: std::exception
struct invalid_encoding: std::exception
{
// hidden
virtual const char* what() const TORRENT_EXCEPTION_THROW_SPECIFIER

View File

@ -360,12 +360,12 @@ namespace libtorrent
// returns a range of all pieces. This migh be a very
// long list, use carefully
std::pair<iterator, iterator> all_pieces() const;
int num_pieces() const { return m_pieces.size(); }
int num_pieces() const { return int(m_pieces.size()); }
list_iterator<cached_piece_entry> write_lru_pieces() const
{ return m_lru[cached_piece_entry::write_lru].iterate(); }
int num_write_lru_pieces() const { return m_lru[cached_piece_entry::write_lru].size(); }
int num_write_lru_pieces() const { return int(m_lru[cached_piece_entry::write_lru].size()); }
// mark this piece for deletion. If there are no outstanding
// requests to this piece, it's removed immediately, and the

View File

@ -79,7 +79,7 @@ namespace libtorrent
void send(char const* buffer, int size, error_code& ec, int flags = 0);
void close();
int num_send_sockets() const { return m_unicast_sockets.size(); }
int num_send_sockets() const { return int(m_unicast_sockets.size()); }
void enable_ip_broadcast(bool e);
private:

View File

@ -50,7 +50,7 @@ namespace libtorrent
struct disk_io_thread;
struct disk_observer;
struct buffer_allocator_interface
struct TORRENT_EXTRA_EXPORT buffer_allocator_interface
{
virtual char* allocate_disk_buffer(char const* category) = 0;
virtual void free_disk_buffer(char* b) = 0;

View File

@ -50,7 +50,7 @@ namespace libtorrent
struct add_torrent_params;
struct cache_status;
struct disk_interface
struct TORRENT_EXTRA_EXPORT disk_interface
{
virtual void async_read(piece_manager* storage, peer_request const& r
, boost::function<void(disk_io_job const*)> const& handler, void* requester

View File

@ -46,7 +46,7 @@ namespace libtorrent
{
struct disk_io_job;
struct disk_job_pool
struct TORRENT_EXTRA_EXPORT disk_job_pool
{
disk_job_pool();
~disk_job_pool();

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct disk_observer
struct TORRENT_EXTRA_EXPORT disk_observer
{
// called when the disk cache size has dropped
// below the low watermark again and we can

View File

@ -88,7 +88,7 @@ namespace libtorrent
// thrown by any accessor function of entry if the accessor
// function requires a type different than the actual type
// of the entry object.
struct TORRENT_EXPORT type_error: std::runtime_error
struct type_error : std::runtime_error
{
// internal
type_error(const char* error): std::runtime_error(error) {}

View File

@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
struct dht_logger
struct TORRENT_EXTRA_EXPORT dht_logger
{
enum module_t
{
@ -64,7 +64,7 @@ namespace libtorrent { namespace dht
~dht_logger() {}
};
struct dht_observer : dht_logger
struct TORRENT_EXTRA_EXPORT dht_observer : dht_logger
{
virtual void set_external_address(address const& addr
, address const& source) = 0;

View File

@ -128,7 +128,6 @@ namespace libtorrent
struct TORRENT_EXTRA_EXPORT peer_class_pool
{
peer_class_t new_peer_class(std::string const& label);
void decref(peer_class_t c);
void incref(peer_class_t c);

View File

@ -40,7 +40,7 @@ namespace libtorrent {
// this represents an object that can have many peer classes applied
// to it. Most notably, peer connections and torrents derive from this.
struct peer_class_set
struct TORRENT_EXTRA_EXPORT peer_class_set
{
peer_class_set() : m_size(0) {}
void add_class(peer_class_pool& pool, peer_class_t c);

View File

@ -175,7 +175,7 @@ namespace libtorrent
// internal
inline void nop(char*, void*, block_cache_reference) {}
struct peer_connection_hot_members
struct TORRENT_EXTRA_EXPORT peer_connection_hot_members
{
// if tor is set, this is an outgoing connection
peer_connection_hot_members(
@ -1274,8 +1274,11 @@ namespace libtorrent
m_need_uncork = true;
}
~cork() { if (m_need_uncork) m_pc.uncork_socket(); }
private:
peer_connection& m_pc;
bool m_need_uncork;
cork& operator=(cork const&);
};
}

View File

@ -45,7 +45,7 @@ namespace libtorrent
struct peer_info;
// TODO: make this interface smaller!
struct peer_connection_interface
struct TORRENT_EXTRA_EXPORT peer_connection_interface
{
virtual tcp::endpoint const& remote() const = 0;
virtual tcp::endpoint local_endpoint() const = 0;

View File

@ -53,7 +53,7 @@ namespace libtorrent
// in other torrents.
struct TORRENT_EXTRA_EXPORT resolve_links
{
struct link_t
struct TORRENT_EXTRA_EXPORT link_t
{
boost::shared_ptr<const torrent_info> ti;
std::string save_path;

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct resolver_interface
struct TORRENT_EXTRA_EXPORT resolver_interface
{
typedef boost::function<void(error_code const&, std::vector<address> const&)>
callback_t;

View File

@ -73,7 +73,7 @@ namespace libtorrent
: m_impl(impl)
{}
bool is_valid() const { return m_impl; }
bool is_valid() const { return m_impl != NULL; }
// TODO: 2 the ip filter should probably be saved here too

View File

@ -136,7 +136,7 @@ namespace libtorrent
sha1_hash& operator<<=(int n)
{
TORRENT_ASSERT(n >= 0);
const size_t num_words = size_t(n) / 32;
const int num_words = n / 32;
if (num_words >= number_size)
{
std::memset(m_number, 0, size);
@ -175,7 +175,7 @@ namespace libtorrent
sha1_hash& operator>>=(int n)
{
TORRENT_ASSERT(n >= 0);
const size_t num_words = size_t(n) / 32;
const int num_words = n / 32;
if (num_words >= number_size)
{
std::memset(m_number, 0, size_t(size));

View File

@ -327,7 +327,7 @@ namespace libtorrent
>::value
};
boost::aligned_storage<storage_size, 16>::type m_data;
boost::aligned_storage<storage_size, 8>::type m_data;
};
// returns true if this socket is an SSL socket

View File

@ -625,7 +625,7 @@ namespace libtorrent
void add_piece(cached_piece_entry* p);
void remove_piece(cached_piece_entry* p);
bool has_piece(cached_piece_entry const* p) const;
int num_pieces() const { return m_cached_pieces.size(); }
int num_pieces() const { return int(m_cached_pieces.size()); }
boost::unordered_set<cached_piece_entry*> const& cached_pieces() const
{ return m_cached_pieces; }
private:

View File

@ -177,7 +177,7 @@ namespace libtorrent
std::vector<char> restart_piece;
};
struct torrent_hot_members
struct TORRENT_EXTRA_EXPORT torrent_hot_members
{
torrent_hot_members(aux::session_interface& ses
, add_torrent_params const& p, int block_size);
@ -1018,7 +1018,7 @@ namespace libtorrent
bool are_files_checked() const
{ return m_files_checked; }
bool valid_storage() const
{ return m_storage.get(); }
{ return m_storage.get() != NULL; }
// parses the info section from the given
// bencoded tree and moves the torrent
@ -1107,7 +1107,7 @@ namespace libtorrent
#endif
int num_time_critical_pieces() const
{ return m_time_critical_pieces.size(); }
{ return int(m_time_critical_pieces.size()); }
private:

View File

@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct torrent_peer_allocator_interface
struct TORRENT_EXTRA_EXPORT torrent_peer_allocator_interface
{
enum peer_type_t
{

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct udp_socket_observer
struct TORRENT_EXTRA_EXPORT udp_socket_observer
{
// return true if the packet was handled (it won't be
// propagated to the next observer)

View File

@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_UNCORK_INTERFACE_HPP
#define TORRENT_UNCORK_INTERFACE_HPP
#include "libtorrent/export.hpp"
namespace libtorrent
{
// the uncork interface is used by the disk_io_thread
@ -45,7 +47,7 @@ namespace libtorrent
// kernel per system call.
// uncorking refers to releasing the "cork" in the peers
// preventing them to issue sends
struct uncork_interface
struct TORRENT_EXTRA_EXPORT uncork_interface
{
virtual void do_delayed_uncork() = 0;
protected:

View File

@ -313,7 +313,7 @@ public:
m_connect_handler = handler;
do_connect(endpoint);
}
template <class Mutable_Buffers, class Handler>
void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
{
@ -329,7 +329,7 @@ public:
m_io_service.post(boost::bind<void>(handler, boost::asio::error::operation_not_supported, 0));
return;
}
int bytes_added = 0;
std::size_t bytes_added = 0;
for (typename Mutable_Buffers::const_iterator i = buffers.begin()
, end(buffers.end()); i != end; ++i)
{
@ -465,7 +465,7 @@ public:
return;
}
int bytes_added = 0;
std::size_t bytes_added = 0;
for (typename Const_Buffers::const_iterator i = buffers.begin()
, end(buffers.end()); i != end; ++i)
{

View File

@ -105,6 +105,7 @@ namespace libtorrent
std::string get_symlink_path(std::string const& p)
{
#if defined TORRENT_WINDOWS
TORRENT_UNUSED(p);
return "";
#else
std::string path = convert_to_native(p);
@ -361,7 +362,7 @@ namespace libtorrent
#endif
m_files.set_piece_length(piece_size);
if (flags & (optimize_alignment | mutable_torrent_support))
m_files.optimize(pad_file_limit, alignment, flags & mutable_torrent_support);
m_files.optimize(pad_file_limit, alignment, (flags & mutable_torrent_support) != 0);
m_files.set_num_pieces(static_cast<int>(
(m_files.total_size() + m_files.piece_length() - 1) / m_files.piece_length()));

View File

@ -463,6 +463,8 @@ namespace libtorrent
void disk_buffer_pool::set_settings(aux::session_settings const& sett
, error_code& ec)
{
TORRENT_UNUSED(ec);
mutex::scoped_lock l(m_pool_mutex);
// 0 cache_buffer_chunk_size means 'automatic' (i.e.

View File

@ -309,10 +309,10 @@ namespace libtorrent
{
int bufs_size(file::iovec_t const* bufs, int num_bufs)
{
int size = 0;
std::size_t size = 0;
for (file::iovec_t const* i = bufs, *end(bufs + num_bufs); i < end; ++i)
size += i->iov_len;
return size;
return int(size);
}
#ifdef TORRENT_WINDOWS
@ -341,6 +341,8 @@ namespace libtorrent
ec.clear();
#ifdef TORRENT_WINDOWS
TORRENT_UNUSED(flags);
#if TORRENT_USE_WSTRING && defined TORRENT_WINDOWS
#define GetFileAttributesEx_ GetFileAttributesExW
std::wstring f = convert_to_wstring(inf);
@ -1546,7 +1548,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
}
else if (ret == FALSE)
{
int error = GetLastError();
// int error = GetLastError();
return true;
}
@ -1616,7 +1618,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
void gather_copy(file::iovec_t const* bufs, int num_bufs, char* dst)
{
int offset = 0;
std::size_t offset = 0;
for (int i = 0; i < num_bufs; ++i)
{
memcpy(dst + offset, bufs[i].iov_base, bufs[i].iov_len);
@ -1626,7 +1628,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
void scatter_copy(file::iovec_t const* bufs, int num_bufs, char const* src)
{
int offset = 0;
std::size_t offset = 0;
for (int i = 0; i < num_bufs; ++i)
{
memcpy(bufs[i].iov_base, src + offset, bufs[i].iov_len);

View File

@ -56,14 +56,14 @@ namespace libtorrent
if (!st.name.empty())
{
ret += "&dn=";
ret += escape_string(st.name.c_str(), st.name.length());
ret += escape_string(st.name.c_str(), int(st.name.length()));
}
std::vector<announce_entry> const& tr = handle.trackers();
for (std::vector<announce_entry>::const_iterator i = tr.begin(), end(tr.end()); i != end; ++i)
{
ret += "&tr=";
ret += escape_string(i->url.c_str(), i->url.length());
ret += escape_string(i->url.c_str(), int(i->url.length()));
}
std::set<std::string> seeds = handle.url_seeds();
@ -71,7 +71,7 @@ namespace libtorrent
, end(seeds.end()); i != end; ++i)
{
ret += "&ws=";
ret += escape_string(i->c_str(), i->length());
ret += escape_string(i->c_str(), int(i->length()));
}
return ret;

View File

@ -97,7 +97,8 @@ namespace libtorrent { namespace
return ret;
}
struct metadata_plugin : torrent_plugin
struct metadata_plugin TORRENT_FINAL
: torrent_plugin
{
metadata_plugin(torrent& t)
: m_torrent(t)
@ -111,19 +112,19 @@ namespace libtorrent { namespace
bool need_loaded()
{ return m_torrent.need_loaded(); }
*/
virtual void on_unload()
virtual void on_unload() TORRENT_OVERRIDE
{
m_metadata.reset();
}
virtual void on_load()
virtual void on_load() TORRENT_OVERRIDE
{
// initialize m_metadata_size
TORRENT_ASSERT(m_torrent.is_loaded());
metadata();
}
virtual void on_files_checked()
virtual void on_files_checked() TORRENT_OVERRIDE
{
// if the torrent is a seed, make a reference to
// the metadata from the torrent before it is deallocated
@ -131,7 +132,7 @@ namespace libtorrent { namespace
}
virtual boost::shared_ptr<peer_plugin> new_connection(
peer_connection_handle const& pc);
peer_connection_handle const& pc) TORRENT_OVERRIDE;
buffer::const_interval metadata() const
{
@ -251,10 +252,13 @@ namespace libtorrent { namespace
// this vector keeps track of how many times each meatdata
// block has been requested
std::vector<int> m_requested_metadata;
// explicitly disallow assignment, to silence msvc warning
metadata_plugin& operator=(metadata_plugin const&);
};
struct metadata_peer_plugin : peer_plugin
struct metadata_peer_plugin TORRENT_FINAL
: peer_plugin
{
metadata_peer_plugin(torrent& t, peer_connection& pc
, metadata_plugin& tp)
@ -268,17 +272,17 @@ namespace libtorrent { namespace
, m_tp(tp)
{}
virtual char const* type() const { return "LT_metadata"; }
virtual char const* type() const TORRENT_OVERRIDE { return "LT_metadata"; }
// can add entries to the extension handshake
virtual void add_handshake(entry& h)
virtual void add_handshake(entry& h) TORRENT_OVERRIDE
{
entry& messages = h["m"];
messages["LT_metadata"] = 14;
}
// called when the extension handshake from the other end is received
virtual bool on_extension_handshake(bdecode_node const& h)
virtual bool on_extension_handshake(bdecode_node const& h) TORRENT_OVERRIDE
{
m_message_index = 0;
if (h.type() != bdecode_node::dict_t) return false;
@ -385,7 +389,7 @@ namespace libtorrent { namespace
}
virtual bool on_extended(int length
, int msg, buffer::const_interval body)
, int msg, buffer::const_interval body) TORRENT_OVERRIDE
{
if (msg != 14) return false;
if (m_message_index == 0) return false;
@ -487,7 +491,7 @@ namespace libtorrent { namespace
return true;
}
virtual void tick()
virtual void tick() TORRENT_OVERRIDE
{
if (m_pc.is_disconnecting()) return;
@ -518,7 +522,7 @@ namespace libtorrent { namespace
// request to this peer, and reset to false when
// we receive a reply to our request.
bool m_waiting_metadata_request;
// this is the message index the remote peer uses
// for metadata extension messages.
int m_message_index;
@ -545,6 +549,9 @@ namespace libtorrent { namespace
torrent& m_torrent;
peer_connection& m_pc;
metadata_plugin& m_tp;
// explicitly disallow assignment, to silence msvc warning
metadata_peer_plugin& operator=(metadata_peer_plugin const&);
};
boost::shared_ptr<peer_plugin> metadata_plugin::new_connection(

View File

@ -118,7 +118,9 @@ namespace libtorrent {
namespace
{
struct smart_ban_plugin : torrent_plugin, boost::enable_shared_from_this<smart_ban_plugin>
struct smart_ban_plugin TORRENT_FINAL
: torrent_plugin
, boost::enable_shared_from_this<smart_ban_plugin>
{
smart_ban_plugin(torrent& t)
: m_torrent(t)
@ -134,7 +136,7 @@ namespace
{ fclose(m_log_file); }
#endif
void on_piece_pass(int p)
virtual void on_piece_pass(int p) TORRENT_OVERRIDE
{
#ifndef TORRENT_DISABLE_LOGGING
m_torrent.debug_log(" PIECE PASS [ p: %d | block_hash_size: %d ]"
@ -186,7 +188,7 @@ namespace
}
}
void on_piece_failed(int p)
virtual void on_piece_failed(int p) TORRENT_OVERRIDE
{
// The piece failed the hash check. Record
// the CRC and origin peer of every block
@ -315,7 +317,7 @@ namespace
, print_address(p->ip().address()).c_str());
#endif
}
void on_read_ok_block(std::pair<piece_block, block_entry> b, address a, disk_io_job const* j)
{
TORRENT_ASSERT(m_torrent.session().is_single_thread());
@ -368,7 +370,7 @@ namespace
if (p->connection) p->connection->disconnect(
errors::peer_banned, op_bittorrent);
}
torrent& m_torrent;
// This table maps a piece_block (piece and block index
@ -385,6 +387,8 @@ namespace
#ifdef TORRENT_LOG_HASH_FAILURES
FILE* m_log_file;
#endif
// explicitly disallow assignment, to silence msvc warning
smart_ban_plugin& operator=(smart_ban_plugin const&);
};
} }

View File

@ -170,14 +170,14 @@ namespace libtorrent
, add_torrent_params const& p, int block_size)
: m_ses(ses)
, m_complete(0xffffff)
, m_upload_mode(p.flags & add_torrent_params::flag_upload_mode)
, m_upload_mode((p.flags & add_torrent_params::flag_upload_mode) != 0)
, m_connections_initialized(false)
, m_abort(false)
, m_allow_peers((p.flags & add_torrent_params::flag_paused) == 0)
, m_share_mode(p.flags & add_torrent_params::flag_share_mode)
, m_share_mode((p.flags & add_torrent_params::flag_share_mode) != 0)
, m_have_all(false)
, m_graceful_pause_mode(false)
, m_state_subscription(p.flags & add_torrent_params::flag_update_subscribe)
, m_state_subscription((p.flags & add_torrent_params::flag_update_subscribe) != 0)
, m_max_connections(0xffffff)
, m_block_size_shift(root2(block_size))
, m_state(torrent_status::checking_resume_data)
@ -237,7 +237,7 @@ namespace libtorrent
, m_got_tracker_response(false)
, m_seed_mode(false)
, m_super_seeding(false)
, m_override_resume_data(p.flags & add_torrent_params::flag_override_resume_data)
, m_override_resume_data((p.flags & add_torrent_params::flag_override_resume_data) != 0)
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
, m_resolving_country(false)
, m_resolve_countries(false)
@ -251,8 +251,8 @@ namespace libtorrent
, m_need_connect_boost(true)
, m_lsd_seq(0)
, m_magnet_link(false)
, m_apply_ip_filter(p.flags & add_torrent_params::flag_apply_ip_filter)
, m_merge_resume_trackers(p.flags & add_torrent_params::flag_merge_resume_trackers)
, m_apply_ip_filter((p.flags & add_torrent_params::flag_apply_ip_filter) != 0)
, m_merge_resume_trackers((p.flags & add_torrent_params::flag_merge_resume_trackers) != 0)
, m_padding(0)
, m_priority(0)
, m_incomplete(0xffffff)
@ -262,7 +262,7 @@ namespace libtorrent
, m_is_active_finished(false)
, m_ssl_torrent(false)
, m_deleted(false)
, m_pinned(p.flags & add_torrent_params::flag_pinned)
, m_pinned((p.flags & add_torrent_params::flag_pinned) != 0)
, m_should_be_loaded(true)
, m_last_download((std::numeric_limits<boost::int16_t>::min)())
, m_num_seeds(0)
@ -277,9 +277,9 @@ namespace libtorrent
, m_last_scrape((std::numeric_limits<boost::int16_t>::min)())
, m_progress_ppm(0)
, m_pending_active_change(false)
, m_use_resume_save_path(p.flags & add_torrent_params::flag_use_resume_save_path)
, m_merge_resume_http_seeds(p.flags & add_torrent_params::flag_merge_resume_http_seeds)
, m_stop_when_ready(p.flags & add_torrent_params::flag_stop_when_ready)
, m_use_resume_save_path((p.flags & add_torrent_params::flag_use_resume_save_path) != 0)
, m_merge_resume_http_seeds((p.flags & add_torrent_params::flag_merge_resume_http_seeds) != 0)
, m_stop_when_ready((p.flags & add_torrent_params::flag_stop_when_ready) != 0)
{
// we cannot log in the constructor, because it relies on shared_from_this
// being initialized, which happens after the constructor returns.
@ -331,7 +331,7 @@ namespace libtorrent
m_trackers = m_torrent_file->trackers();
if (m_torrent_file->is_valid())
{
m_seed_mode = p.flags & add_torrent_params::flag_seed_mode;
m_seed_mode = (p.flags & add_torrent_params::flag_seed_mode) != 0;
m_connections_initialized = true;
m_block_size_shift = root2((std::min)(block_size, m_torrent_file->piece_length()));
}
@ -3506,7 +3506,7 @@ namespace libtorrent
i != resp.peers4.end(); ++i)
{
tcp::endpoint a(address_v4(i->ip), i->port);
need_update |= bool(add_peer(a, peer_info::tracker));
need_update |= bool(add_peer(a, peer_info::tracker) != NULL);
}
#if TORRENT_USE_IPV6
@ -3514,7 +3514,7 @@ namespace libtorrent
i != resp.peers6.end(); ++i)
{
tcp::endpoint a(address_v6(i->ip), i->port);
need_update |= bool(add_peer(a, peer_info::tracker));
need_update |= bool(add_peer(a, peer_info::tracker) != NULL);
}
#endif
if (need_update) state_updated();
@ -6774,27 +6774,27 @@ namespace libtorrent
if (seed_mode_ != -1) m_seed_mode = seed_mode_ && m_torrent_file->is_valid();
int super_seeding_ = rd.dict_find_int_value("super_seeding", -1);
if (super_seeding_ != -1) super_seeding(super_seeding_);
if (super_seeding_ != -1) super_seeding(super_seeding_ != 0);
int auto_managed_ = rd.dict_find_int_value("auto_managed", -1);
if (auto_managed_ != -1)
{
m_auto_managed = auto_managed_;
m_auto_managed = auto_managed_ != 0;
update_want_scrape();
update_state_list();
}
int sequential_ = rd.dict_find_int_value("sequential_download", -1);
if (sequential_ != -1) set_sequential_download(sequential_);
if (sequential_ != -1) set_sequential_download(sequential_ != 0);
int paused_ = rd.dict_find_int_value("paused", -1);
if (paused_ != -1)
{
set_allow_peers(!paused_);
m_announce_to_dht = !paused_;
m_announce_to_trackers = !paused_;
m_announce_to_lsd = !paused_;
set_allow_peers(paused_ == 0);
m_announce_to_dht = (paused_ == 0);
m_announce_to_trackers = (paused_ == 0);
m_announce_to_lsd = (paused_ == 0);
update_gauge();
update_want_peers();
@ -6802,11 +6802,11 @@ namespace libtorrent
update_state_list();
}
int dht_ = rd.dict_find_int_value("announce_to_dht", -1);
if (dht_ != -1) m_announce_to_dht = dht_;
if (dht_ != -1) m_announce_to_dht = (dht_ != 0);
int lsd_ = rd.dict_find_int_value("announce_to_lsd", -1);
if (lsd_ != -1) m_announce_to_lsd = lsd_;
if (lsd_ != -1) m_announce_to_lsd = (lsd_ != 0);
int track_ = rd.dict_find_int_value("announce_to_trackers", -1);
if (track_ != -1) m_announce_to_trackers = track_;
if (track_ != -1) m_announce_to_trackers = (track_ != 0);
#ifndef TORRENT_DISABLE_LOGGING
debug_log("loaded resume data: max-uploads: %d max-connections: %d "
@ -7707,7 +7707,7 @@ namespace libtorrent
if (m_share_mode)
recalc_share_mode();
return peerinfo->connection;
return peerinfo->connection != NULL;
}
bool torrent::set_metadata(char const* metadata_buf, int metadata_size)
@ -11852,7 +11852,7 @@ namespace libtorrent
st->is_finished = is_finished();
st->super_seeding = m_super_seeding;
st->has_metadata = valid_metadata();
bytes_done(*st, flags & torrent_handle::query_accurate_download_counters);
bytes_done(*st, (flags & torrent_handle::query_accurate_download_counters) != 0);
TORRENT_ASSERT(st->total_wanted_done >= 0);
TORRENT_ASSERT(st->total_done >= st->total_wanted_done);

View File

@ -1090,7 +1090,7 @@ namespace libtorrent
m_orig_files.reset(new file_storage(m_files));
}
#define SWAP(a, b) \
#define SWAP(tmp, a, b) \
tmp = a; \
a = b; \
b = tmp;
@ -1109,16 +1109,19 @@ namespace libtorrent
swap(m_creation_date, ti.m_creation_date);
m_comment.swap(ti.m_comment);
m_created_by.swap(ti.m_created_by);
boost::uint32_t tmp;
SWAP(m_multifile, ti.m_multifile);
SWAP(m_private, ti.m_private);
SWAP(m_i2p, ti.m_i2p);
swap(m_info_section, ti.m_info_section);
SWAP(m_info_section_size, ti.m_info_section_size);
swap(m_piece_hashes, ti.m_piece_hashes);
m_info_dict.swap(ti.m_info_dict);
swap(m_merkle_tree, ti.m_merkle_tree);
SWAP(m_merkle_first_leaf, ti.m_merkle_first_leaf);
std::swap(m_info_section_size, ti.m_info_section_size);
boost::uint32_t tmp;
SWAP(tmp, m_merkle_first_leaf, ti.m_merkle_first_leaf);
bool tmp2;
SWAP(tmp2, m_private, ti.m_private);
SWAP(tmp2, m_i2p, ti.m_i2p);
SWAP(tmp2, m_multifile, ti.m_multifile);
}
#undef SWAP

View File

@ -90,7 +90,8 @@ namespace libtorrent { namespace
struct ut_metadata_peer_plugin;
struct ut_metadata_plugin : torrent_plugin
struct ut_metadata_plugin TORRENT_FINAL
: torrent_plugin
{
ut_metadata_plugin(torrent& t)
: m_torrent(t)
@ -105,19 +106,19 @@ namespace libtorrent { namespace
bool need_loaded()
{ return m_torrent.need_loaded(); }
virtual void on_unload()
virtual void on_unload() TORRENT_OVERRIDE
{
m_metadata.reset();
}
virtual void on_load()
virtual void on_load() TORRENT_OVERRIDE
{
// initialize m_metadata_size
TORRENT_ASSERT(m_torrent.is_loaded());
metadata();
}
virtual void on_files_checked()
virtual void on_files_checked() TORRENT_OVERRIDE
{
// TODO: 2 if we were to initialize m_metadata_size lazily instead,
// we would probably be more efficient
@ -126,7 +127,7 @@ namespace libtorrent { namespace
}
virtual boost::shared_ptr<peer_plugin> new_connection(
peer_connection_handle const& pc);
peer_connection_handle const& pc) TORRENT_OVERRIDE;
int get_metadata_size() const
{
@ -208,10 +209,14 @@ namespace libtorrent { namespace
// block has been requested and who we ended up getting it from
// std::numeric_limits<int>::max() means we have the piece
std::vector<metadata_piece> m_requested_metadata;
// explicitly disallow assignment, to silence msvc warning
ut_metadata_plugin& operator=(ut_metadata_plugin const&);
};
struct ut_metadata_peer_plugin : peer_plugin, boost::enable_shared_from_this<ut_metadata_peer_plugin>
struct ut_metadata_peer_plugin TORRENT_FINAL
: peer_plugin, boost::enable_shared_from_this<ut_metadata_peer_plugin>
{
friend struct ut_metadata_plugin;
@ -224,10 +229,10 @@ namespace libtorrent { namespace
, m_tp(tp)
{}
virtual char const* type() const { return "ut_metadata"; }
virtual char const* type() const TORRENT_OVERRIDE { return "ut_metadata"; }
// can add entries to the extension handshake
virtual void add_handshake(entry& h)
virtual void add_handshake(entry& h) TORRENT_OVERRIDE
{
entry& messages = h["m"];
messages["ut_metadata"] = 2;
@ -236,7 +241,7 @@ namespace libtorrent { namespace
}
// called when the extension handshake from the other end is received
virtual bool on_extension_handshake(bdecode_node const& h)
virtual bool on_extension_handshake(bdecode_node const& h) TORRENT_OVERRIDE
{
m_message_index = 0;
if (h.type() != bdecode_node::dict_t) return false;
@ -322,7 +327,7 @@ namespace libtorrent { namespace
}
virtual bool on_extended(int length
, int extended_msg, buffer::const_interval body)
, int extended_msg, buffer::const_interval body) TORRENT_OVERRIDE
{
if (extended_msg != 2) return false;
if (m_message_index == 0) return false;
@ -438,7 +443,7 @@ namespace libtorrent { namespace
return true;
}
virtual void tick()
virtual void tick() TORRENT_OVERRIDE
{
maybe_send_request();
while (!m_incoming_requests.empty()
@ -500,6 +505,9 @@ namespace libtorrent { namespace
torrent& m_torrent;
bt_peer_connection& m_pc;
ut_metadata_plugin& m_tp;
// explicitly disallow assignment, to silence msvc warning
ut_metadata_peer_plugin& operator=(ut_metadata_peer_plugin const&);
};
boost::shared_ptr<peer_plugin> ut_metadata_plugin::new_connection(
@ -547,7 +555,7 @@ namespace libtorrent { namespace
return piece;
}
inline bool ut_metadata_plugin::received_metadata(
bool ut_metadata_plugin::received_metadata(
ut_metadata_peer_plugin& source
, char const* buf, int size, int piece, int total_size)
{

View File

@ -81,7 +81,8 @@ namespace libtorrent { namespace
return true;
}
struct ut_pex_plugin: torrent_plugin
struct ut_pex_plugin TORRENT_FINAL
: torrent_plugin
{
// randomize when we rebuild the pex message
// to evenly spread it out across all torrents
@ -91,8 +92,9 @@ namespace libtorrent { namespace
: m_torrent(t)
, m_last_msg(min_time())
, m_peers_in_message(0) {}
virtual boost::shared_ptr<peer_plugin> new_connection(peer_connection_handle const& pc);
virtual boost::shared_ptr<peer_plugin> new_connection(
peer_connection_handle const& pc) TORRENT_OVERRIDE;
std::vector<char>& get_ut_pex_msg()
{
@ -109,7 +111,7 @@ namespace libtorrent { namespace
// are calculated here and the pex message is created
// each peer connection will use this message
// max_peer_entries limits the packet size
virtual void tick()
virtual void tick() TORRENT_OVERRIDE
{
time_point now = aux::time_now();
if (now - seconds(60) < m_last_msg) return;
@ -231,11 +233,14 @@ namespace libtorrent { namespace
time_point m_last_msg;
std::vector<char> m_ut_pex_msg;
int m_peers_in_message;
// explicitly disallow assignment, to silence msvc warning
ut_pex_plugin& operator=(ut_pex_plugin const&);
};
struct ut_pex_peer_plugin : peer_plugin
{
struct ut_pex_peer_plugin TORRENT_FINAL
: peer_plugin
{
ut_pex_peer_plugin(torrent& t, peer_connection& pc, ut_pex_plugin& tp)
: m_torrent(t)
, m_pc(pc)
@ -251,15 +256,15 @@ namespace libtorrent { namespace
}
}
virtual char const* type() const { return "ut_pex"; }
virtual char const* type() const TORRENT_OVERRIDE { return "ut_pex"; }
virtual void add_handshake(entry& h)
virtual void add_handshake(entry& h) TORRENT_OVERRIDE
{
entry& messages = h["m"];
messages[extension_name] = extension_index;
}
virtual bool on_extension_handshake(bdecode_node const& h)
virtual bool on_extension_handshake(bdecode_node const& h) TORRENT_OVERRIDE
{
m_message_index = 0;
if (h.type() != bdecode_node::dict_t) return false;
@ -272,7 +277,7 @@ namespace libtorrent { namespace
return true;
}
virtual bool on_extended(int length, int msg, buffer::const_interval body)
virtual bool on_extended(int length, int msg, buffer::const_interval body) TORRENT_OVERRIDE
{
if (msg != extension_index) return false;
if (m_message_index == 0) return false;
@ -282,7 +287,7 @@ namespace libtorrent { namespace
m_pc.disconnect(errors::pex_message_too_large, op_bittorrent, 2);
return true;
}
if (body.left() < length) return true;
time_point now = aux::time_now();
@ -378,7 +383,7 @@ namespace libtorrent { namespace
peers6_t::value_type v(adr.address().to_v6().to_bytes(), adr.port());
peers6_t::iterator j = std::lower_bound(m_peers6.begin(), m_peers6.end(), v);
if (j != m_peers6.end() && *j == v) m_peers6.erase(j);
}
}
}
p6 = pex_msg.dict_find("added6");
@ -425,7 +430,7 @@ namespace libtorrent { namespace
// the peers second tick
// every minute we send a pex message
virtual void tick()
virtual void tick() TORRENT_OVERRIDE
{
// no handshake yet
if (!m_message_index) return;
@ -646,6 +651,9 @@ namespace libtorrent { namespace
// it is used to know if a diff message or a) ful
// message should be sent.
bool m_first_time;
// explicitly disallow assignment, to silence msvc warning
ut_pex_peer_plugin& operator=(ut_pex_peer_plugin const&);
};
boost::shared_ptr<peer_plugin> ut_pex_plugin::new_connection(peer_connection_handle const& pc)