forked from premiere/premiere-libtorrent
more headers code cleanup and some lint oriented refactor
This commit is contained in:
parent
35da7fb0e6
commit
fedee2b5fa
|
@ -209,9 +209,9 @@ namespace aux {
|
||||||
|
|
||||||
struct TORRENT_EXTRA_EXPORT listen_endpoint_t
|
struct TORRENT_EXTRA_EXPORT listen_endpoint_t
|
||||||
{
|
{
|
||||||
listen_endpoint_t(address adr, int p, std::string dev, transport s
|
listen_endpoint_t(address const& adr, int p, std::string dev, transport s
|
||||||
, duplex d = duplex::accept_incoming)
|
, duplex d = duplex::accept_incoming)
|
||||||
: addr(adr), port(p), device(dev), ssl(s), incoming(d) {}
|
: addr(adr), port(p), device(std::move(dev)), ssl(s), incoming(d) {}
|
||||||
|
|
||||||
bool operator==(listen_endpoint_t const& o) const
|
bool operator==(listen_endpoint_t const& o) const
|
||||||
{
|
{
|
||||||
|
@ -289,7 +289,7 @@ namespace aux {
|
||||||
|
|
||||||
struct session_plugin_wrapper : plugin
|
struct session_plugin_wrapper : plugin
|
||||||
{
|
{
|
||||||
explicit session_plugin_wrapper(ext_function_t const& f) : m_f(f) {}
|
explicit session_plugin_wrapper(ext_function_t f) : m_f(std::move(f)) {}
|
||||||
|
|
||||||
std::shared_ptr<torrent_plugin> new_torrent(torrent_handle const& t, void* user) override
|
std::shared_ptr<torrent_plugin> new_torrent(torrent_handle const& t, void* user) override
|
||||||
{ return m_f(t, user); }
|
{ return m_f(t, user); }
|
||||||
|
@ -592,7 +592,6 @@ namespace aux {
|
||||||
|
|
||||||
void get_cache_info(torrent_handle h, cache_status* ret, int flags) const;
|
void get_cache_info(torrent_handle h, cache_status* ret, int flags) const;
|
||||||
|
|
||||||
void set_key(std::uint32_t key);
|
|
||||||
std::uint16_t listen_port() const override;
|
std::uint16_t listen_port() const override;
|
||||||
std::uint16_t listen_port(listen_socket_t* sock) const;
|
std::uint16_t listen_port(listen_socket_t* sock) const;
|
||||||
std::uint16_t ssl_listen_port() const override;
|
std::uint16_t ssl_listen_port() const override;
|
||||||
|
@ -659,9 +658,6 @@ namespace aux {
|
||||||
|
|
||||||
void deferred_submit_jobs() override;
|
void deferred_submit_jobs() override;
|
||||||
|
|
||||||
torrent_peer* allocate_peer_entry(int type);
|
|
||||||
void free_peer_entry(torrent_peer* p);
|
|
||||||
|
|
||||||
// implements dht_observer
|
// implements dht_observer
|
||||||
void set_external_address(aux::listen_socket_handle const& iface
|
void set_external_address(aux::listen_socket_handle const& iface
|
||||||
, address const& ip, address const& source) override;
|
, address const& ip, address const& source) override;
|
||||||
|
@ -788,7 +784,7 @@ namespace aux {
|
||||||
void on_lsd_peer(tcp::endpoint const& peer, sha1_hash const& ih) override;
|
void on_lsd_peer(tcp::endpoint const& peer, sha1_hash const& ih) override;
|
||||||
|
|
||||||
void set_external_address(std::shared_ptr<listen_socket_t> const& sock, address const& ip
|
void set_external_address(std::shared_ptr<listen_socket_t> const& sock, address const& ip
|
||||||
, ip_source_t const source_type, address const& source);
|
, ip_source_t source_type, address const& source);
|
||||||
|
|
||||||
void interface_to_endpoints(std::string const& device, int port
|
void interface_to_endpoints(std::string const& device, int port
|
||||||
, transport ssl, duplex incoming, std::vector<listen_endpoint_t>& eps);
|
, transport ssl, duplex incoming, std::vector<listen_endpoint_t>& eps);
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace aux {
|
||||||
//
|
//
|
||||||
// This data structure is 32 bits aligned, like it's the case for
|
// This data structure is 32 bits aligned, like it's the case for
|
||||||
// each SHA-N specification.
|
// each SHA-N specification.
|
||||||
template <int N>
|
template <std::size_t N>
|
||||||
class digest32
|
class digest32
|
||||||
{
|
{
|
||||||
static_assert(N % 32 == 0, "N must be a multiple of 32");
|
static_assert(N % 32 == 0, "N must be a multiple of 32");
|
||||||
|
|
|
@ -83,35 +83,6 @@ private:
|
||||||
int m_num_samples = 0;
|
int m_num_samples = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct average_accumulator
|
|
||||||
{
|
|
||||||
average_accumulator() {}
|
|
||||||
|
|
||||||
void add_sample(std::int64_t s)
|
|
||||||
{
|
|
||||||
++m_num_samples;
|
|
||||||
m_sample_sum += s;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mean()
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
if (m_num_samples == 0) ret = 0;
|
|
||||||
else ret = int(m_sample_sum / m_num_samples);
|
|
||||||
// in case we don't get any more samples, at least
|
|
||||||
// let the average roll over, but only be worth a
|
|
||||||
// single sample
|
|
||||||
m_num_samples = 1;
|
|
||||||
m_sample_sum = ret;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
int m_num_samples = 0;
|
|
||||||
std::int64_t m_sample_sum = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -366,7 +366,7 @@ namespace libtorrent {
|
||||||
// the file_storage object is owned by the torrent.
|
// the file_storage object is owned by the torrent.
|
||||||
std::shared_ptr<void> m_torrent;
|
std::shared_ptr<void> m_torrent;
|
||||||
|
|
||||||
storage_index_t m_storage_index;
|
storage_index_t m_storage_index{0};
|
||||||
|
|
||||||
// the number of block_cache_reference objects referencing this storage
|
// the number of block_cache_reference objects referencing this storage
|
||||||
std::atomic<int> m_references{1};
|
std::atomic<int> m_references{1};
|
||||||
|
@ -425,8 +425,6 @@ namespace libtorrent {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void delete_one_file(std::string const& p, error_code& ec);
|
|
||||||
|
|
||||||
void need_partfile();
|
void need_partfile();
|
||||||
|
|
||||||
std::unique_ptr<file_storage> m_mapped_files;
|
std::unique_ptr<file_storage> m_mapped_files;
|
||||||
|
|
|
@ -85,9 +85,6 @@ namespace libtorrent {
|
||||||
#endif
|
#endif
|
||||||
namespace aux { struct session_logger; struct session_settings; }
|
namespace aux { struct session_logger; struct session_settings; }
|
||||||
|
|
||||||
// returns -1 if gzip header is invalid or the header size in bytes
|
|
||||||
TORRENT_EXTRA_EXPORT int gzip_header(const char* buf, int size);
|
|
||||||
|
|
||||||
struct TORRENT_EXTRA_EXPORT tracker_request
|
struct TORRENT_EXTRA_EXPORT tracker_request
|
||||||
{
|
{
|
||||||
tracker_request()
|
tracker_request()
|
||||||
|
@ -103,9 +100,6 @@ namespace libtorrent {
|
||||||
, num_want(0)
|
, num_want(0)
|
||||||
, private_torrent(false)
|
, private_torrent(false)
|
||||||
, triggered_manually(false)
|
, triggered_manually(false)
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
|
||||||
, ssl_ctx(0)
|
|
||||||
#endif
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
enum event_t
|
enum event_t
|
||||||
|
@ -167,7 +161,7 @@ namespace libtorrent {
|
||||||
bool triggered_manually;
|
bool triggered_manually;
|
||||||
|
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
#ifdef TORRENT_USE_OPENSSL
|
||||||
boost::asio::ssl::context* ssl_ctx;
|
boost::asio::ssl::context* ssl_ctx = nullptr;
|
||||||
#endif
|
#endif
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
i2p_connection* i2pconn = nullptr;
|
i2p_connection* i2pconn = nullptr;
|
||||||
|
|
|
@ -84,7 +84,6 @@ namespace libtorrent {
|
||||||
|
|
||||||
void name_lookup(error_code const& error
|
void name_lookup(error_code const& error
|
||||||
, std::vector<address> const& addresses, int port);
|
, std::vector<address> const& addresses, int port);
|
||||||
void timeout(error_code const& error);
|
|
||||||
void start_announce();
|
void start_announce();
|
||||||
|
|
||||||
bool on_receive(udp::endpoint const& ep, span<char const> buf);
|
bool on_receive(udp::endpoint const& ep, span<char const> buf);
|
||||||
|
|
Loading…
Reference in New Issue