fix gcc warnings

This commit is contained in:
Arvid Norberg 2015-05-18 01:30:32 +00:00
parent 71ee44ae5e
commit e7d369646d
14 changed files with 98 additions and 104 deletions

View File

@ -260,13 +260,20 @@ namespace libtorrent {
// when the alert queue is full. There are a few alerts which may not be discared, // when the alert queue is full. There are a few alerts which may not be discared,
// since they would break the user contract, such as save_resume_data_alert. // since they would break the user contract, such as save_resume_data_alert.
TORRENT_DEPRECATED TORRENT_DEPRECATED
virtual bool discardable() const { return true; } bool discardable() const { return discardable_impl(); }
TORRENT_DEPRECATED TORRENT_DEPRECATED
severity_t severity() const { return warning; } severity_t severity() const { return warning; }
// returns a pointer to a copy of the alert. // returns a pointer to a copy of the alert.
virtual std::auto_ptr<alert> clone() const = 0; TORRENT_DEPRECATED
std::auto_ptr<alert> clone() const { return clone_impl(); }
protected:
virtual bool discardable_impl() const { return true; }
virtual std::auto_ptr<alert> clone_impl() const = 0;
#endif #endif
private: private:

View File

@ -143,10 +143,13 @@ namespace libtorrent
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
#define TORRENT_CLONE(name) \ #define TORRENT_CLONE(name) \
virtual std::auto_ptr<alert> clone() const \ virtual std::auto_ptr<alert> clone_impl() const TORRENT_OVERRIDE \
{ return std::auto_ptr<alert>(new name(*this)); } { return std::auto_ptr<alert>(new name(*this)); }
#define TORRENT_NOT_DISCARDABLE \
virtual bool discardable_impl() TORRENT_OVERRIDE { return false; }
#else #else
#define TORRENT_CLONE(name) #define TORRENT_CLONE(name)
#define TORRENT_NOT_DISCARDABLE
#endif #endif
#define TORRENT_DEFINE_ALERT_IMPL(name, seq, prio) \ #define TORRENT_DEFINE_ALERT_IMPL(name, seq, prio) \
@ -198,9 +201,7 @@ namespace libtorrent
TORRENT_DEFINE_ALERT_PRIO(torrent_removed_alert, 4) TORRENT_DEFINE_ALERT_PRIO(torrent_removed_alert, 4)
static const int static_category = alert::status_notification; static const int static_category = alert::status_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
sha1_hash info_hash; sha1_hash info_hash;
}; };
@ -212,7 +213,7 @@ namespace libtorrent
// number of bytes that was read. // number of bytes that was read.
// //
// If the operation fails, ec will indicat what went wrong. // If the operation fails, ec will indicat what went wrong.
struct TORRENT_EXPORT read_piece_alert: torrent_alert struct TORRENT_EXPORT read_piece_alert: torrent_alert
{ {
// internal // internal
read_piece_alert(aux::stack_allocator& alloc, torrent_handle const& h read_piece_alert(aux::stack_allocator& alloc, torrent_handle const& h
@ -223,9 +224,7 @@ namespace libtorrent
static const int static_category = alert::storage_notification; static const int static_category = alert::storage_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
error_code ec; error_code ec;
boost::shared_array<char> buffer; boost::shared_array<char> buffer;
@ -263,9 +262,8 @@ namespace libtorrent
static const int static_category = alert::storage_notification; static const int static_category = alert::storage_notification;
virtual std::string message() const; virtual std::string message() const;
TORRENT_NOT_DISCARDABLE
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
std::string name; std::string name;
#endif #endif
@ -291,9 +289,7 @@ namespace libtorrent
static const int static_category = alert::storage_notification; static const int static_category = alert::storage_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// refers to the index of the file that was supposed to be renamed, // refers to the index of the file that was supposed to be renamed,
// ``error`` is the error code returned from the filesystem. // ``error`` is the error code returned from the filesystem.
@ -328,7 +324,7 @@ namespace libtorrent
// is posted, there is a risk that the number of outstanding requests is too low // is posted, there is a risk that the number of outstanding requests is too low
// and limits the download rate. You might want to increase the ``max_out_request_queue`` // and limits the download rate. You might want to increase the ``max_out_request_queue``
// setting. // setting.
outstanding_request_limit_reached, outstanding_request_limit_reached,
// This warning is posted when the amount of TCP/IP overhead is greater than the // This warning is posted when the amount of TCP/IP overhead is greater than the
// upload rate limit. When this happens, the TCP/IP overhead is caused by a much // upload rate limit. When this happens, the TCP/IP overhead is caused by a much
@ -354,7 +350,7 @@ namespace libtorrent
// send it all before the disk gets back to us. // send it all before the disk gets back to us.
// The number of bytes that we keep outstanding, requested from the disk, is calculated // The number of bytes that we keep outstanding, requested from the disk, is calculated
// as follows:: // as follows::
// //
// min(512, max(upload_rate * send_buffer_watermark_factor / 100, send_buffer_watermark)) // min(512, max(upload_rate * send_buffer_watermark_factor / 100, send_buffer_watermark))
// //
// If you receive this alert, you migth want to either increase your ``send_buffer_watermark`` // If you receive this alert, you migth want to either increase your ``send_buffer_watermark``
@ -967,9 +963,7 @@ namespace libtorrent
static const int static_category = alert::storage_notification; static const int static_category = alert::storage_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
sha1_hash info_hash; sha1_hash info_hash;
}; };
@ -988,9 +982,7 @@ namespace libtorrent
| alert::error_notification; | alert::error_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// tells you why it failed. // tells you why it failed.
error_code error; error_code error;
@ -1017,9 +1009,7 @@ namespace libtorrent
static const int static_category = alert::storage_notification; static const int static_category = alert::storage_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// points to the resume data. // points to the resume data.
boost::shared_ptr<entry> resume_data; boost::shared_ptr<entry> resume_data;
@ -1039,9 +1029,7 @@ namespace libtorrent
| alert::error_notification; | alert::error_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// the error code from the resume_data failure // the error code from the resume_data failure
error_code error; error_code error;
@ -1288,9 +1276,9 @@ namespace libtorrent
static const int static_category = alert::status_notification | alert::error_notification; static const int static_category = alert::status_notification | alert::error_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#ifndef TORRENT_NO_DEPRECATE
// the interface libtorrent attempted to listen on // the interface libtorrent attempted to listen on
std::string interface; std::string interface;
#endif #endif
@ -1331,9 +1319,7 @@ namespace libtorrent
static const int static_category = alert::status_notification; static const int static_category = alert::status_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// the endpoint libtorrent ended up listening on. The address // the endpoint libtorrent ended up listening on. The address
// refers to the local interface and the port is the listen port. // refers to the local interface and the port is the listen port.
@ -1774,9 +1760,7 @@ namespace libtorrent
static const int static_category = alert::status_notification; static const int static_category = alert::status_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
error_code error; error_code error;
}; };
@ -1832,9 +1816,7 @@ namespace libtorrent
static const int static_category = alert::status_notification; static const int static_category = alert::status_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// a copy of the parameters used when adding the torrent, it can be used // a copy of the parameters used when adding the torrent, it can be used
// to identify which invocation to ``async_add_torrent()`` caused this alert. // to identify which invocation to ``async_add_torrent()`` caused this alert.
@ -1858,9 +1840,7 @@ namespace libtorrent
static const int static_category = alert::status_notification; static const int static_category = alert::status_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// contains the torrent status of all torrents that changed since last // contains the torrent status of all torrents that changed since last
// time this message was posted. Note that you can map a torrent status // time this message was posted. Note that you can map a torrent status
@ -1893,9 +1873,8 @@ namespace libtorrent
static const int static_category = alert::stats_notification; static const int static_category = alert::stats_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; } TORRENT_NOT_DISCARDABLE
#endif
// An array are a mix of *counters* and *gauges*, which meanings can be // An array are a mix of *counters* and *gauges*, which meanings can be
// queries via the session_stats_metrics() function on the session. The // queries via the session_stats_metrics() function on the session. The
@ -1926,9 +1905,7 @@ namespace libtorrent
static const int static_category = alert::status_notification; static const int static_category = alert::status_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// ``old_ih`` and ``new_ih`` are the previous and new info-hash for the torrent, respectively. // ``old_ih`` and ``new_ih`` are the previous and new info-hash for the torrent, respectively.
sha1_hash old_ih; sha1_hash old_ih;
@ -1996,9 +1973,7 @@ namespace libtorrent
| alert::dht_notification; | alert::dht_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE TORRENT_NOT_DISCARDABLE
virtual bool discardable() const { return false; }
#endif
// the target hash of the immutable item. This must // the target hash of the immutable item. This must
// match the sha-1 hash of the bencoded form of ``item``. // match the sha-1 hash of the bencoded form of ``item``.
@ -2024,9 +1999,8 @@ namespace libtorrent
static const int static_category = alert::error_notification static const int static_category = alert::error_notification
| alert::dht_notification; | alert::dht_notification;
virtual std::string message() const; virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; } TORRENT_NOT_DISCARDABLE
#endif
// the public key that was looked up // the public key that was looked up
boost::array<char, 32> key; boost::array<char, 32> key;

View File

@ -100,7 +100,7 @@ namespace libtorrent
TORRENT_ASSERT(index < size()); TORRENT_ASSERT(index < size());
return (m_buf[index / 32] & htonl((0x80000000 >> (index & 31)))) != 0; return (m_buf[index / 32] & htonl((0x80000000 >> (index & 31)))) != 0;
} }
// set bit at ``index`` to 0 (clear_bit) or 1 (set_bit). // set bit at ``index`` to 0 (clear_bit) or 1 (set_bit).
void clear_bit(int index) void clear_bit(int index)
{ {
@ -159,6 +159,11 @@ namespace libtorrent
// returns a pointer to the internal buffer of the bitfield. // returns a pointer to the internal buffer of the bitfield.
char const* data() const { return reinterpret_cast<char const*>(m_buf); } char const* data() const { return reinterpret_cast<char const*>(m_buf); }
#ifndef TORRENT_NO_DEPRECATE
TORRENT_DEPRECATED
char const* bytes() const { return data(); }
#endif
// copy operator // copy operator
bitfield& operator=(bitfield const& rhs) bitfield& operator=(bitfield const& rhs)
{ {

View File

@ -72,7 +72,7 @@ namespace libtorrent
char const* get_secret() const { return m_dh_shared_secret; } char const* get_secret() const { return m_dh_shared_secret; }
sha1_hash const& get_hash_xor_mask() const { return m_xor_mask; } sha1_hash const& get_hash_xor_mask() const { return m_xor_mask; }
private: private:
int get_local_key_size() const int get_local_key_size() const
@ -126,7 +126,7 @@ namespace libtorrent
// Input keys must be 20 bytes // Input keys must be 20 bytes
void set_incoming_key(unsigned char const* key, int len) TORRENT_OVERRIDE; void set_incoming_key(unsigned char const* key, int len) TORRENT_OVERRIDE;
void set_outgoing_key(unsigned char const* key, int len) TORRENT_OVERRIDE; void set_outgoing_key(unsigned char const* key, int len) TORRENT_OVERRIDE;
int encrypt(std::vector<boost::asio::mutable_buffer>& buf) TORRENT_OVERRIDE; int encrypt(std::vector<boost::asio::mutable_buffer>& buf) TORRENT_OVERRIDE;
void decrypt(std::vector<boost::asio::mutable_buffer>& buf void decrypt(std::vector<boost::asio::mutable_buffer>& buf
, int& consume , int& consume

View File

@ -151,7 +151,7 @@ namespace libtorrent
{ {
return m_v4_outstanding return m_v4_outstanding
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
+ m_v6_outstanding + m_v6_outstanding
#endif #endif
; ;
} }

View File

@ -242,13 +242,14 @@ namespace libtorrent
&& !defined TORRENT_MINGW && !defined TORRENT_MINGW
if (i->interface_address.is_v6() && if (i->interface_address.is_v6() &&
i->interface_address.to_v6().is_link_local()) { i->interface_address.to_v6().is_link_local())
{
address_v6 addr6 = i->interface_address.to_v6(); address_v6 addr6 = i->interface_address.to_v6();
addr6.scope_id(if_nametoindex(i->name)); addr6.scope_id(if_nametoindex(i->name));
open_multicast_socket(ios, addr6, loopback, ec); open_multicast_socket(ios, addr6, loopback, ec);
address_v4 const& mask = i->netmask.is_v4() ? address_v4 const& mask = i->netmask.is_v4()
i->netmask.to_v4() : address_v4(); ? i->netmask.to_v4() : address_v4();
open_unicast_socket(ios, addr6, mask); open_unicast_socket(ios, addr6, mask);
continue; continue;
} }
@ -324,11 +325,13 @@ namespace libtorrent
void broadcast_socket::send(char const* buffer, int size, error_code& ec, int flags) void broadcast_socket::send(char const* buffer, int size, error_code& ec, int flags)
{ {
bool all_fail = true;
error_code e;
for (std::list<socket_entry>::iterator i = m_unicast_sockets.begin() for (std::list<socket_entry>::iterator i = m_unicast_sockets.begin()
, end(m_unicast_sockets.end()); i != end; ++i) , end(m_unicast_sockets.end()); i != end; ++i)
{ {
if (!i->socket) continue; if (!i->socket) continue;
error_code e;
i->socket->send_to(asio::buffer(buffer, size), m_multicast_endpoint, 0, e); i->socket->send_to(asio::buffer(buffer, size), m_multicast_endpoint, 0, e);
// if the user specified the broadcast flag, send one to the broadcast // if the user specified the broadcast flag, send one to the broadcast
@ -337,41 +340,34 @@ namespace libtorrent
i->socket->send_to(asio::buffer(buffer, size) i->socket->send_to(asio::buffer(buffer, size)
, udp::endpoint(i->broadcast_address(), m_multicast_endpoint.port()), 0, e); , udp::endpoint(i->broadcast_address(), m_multicast_endpoint.port()), 0, e);
#ifdef TORRENT_DEBUG
// fprintf(stderr, " sending on unicast %s to: %s\n", print_address(i->socket->local_endpoint().address()).c_str()
// , print_endpoint(m_multicast_endpoint).c_str());
#endif
if (e) if (e)
{ {
#ifdef TORRENT_DEBUG
// fprintf(stderr, " ERROR: %s\n", e.message().c_str());
#endif
i->socket->close(e); i->socket->close(e);
i->socket.reset(); i->socket.reset();
} }
else
{
all_fail = false;
}
} }
for (std::list<socket_entry>::iterator i = m_sockets.begin() for (std::list<socket_entry>::iterator i = m_sockets.begin()
, end(m_sockets.end()); i != end; ++i) , end(m_sockets.end()); i != end; ++i)
{ {
if (!i->socket) continue; if (!i->socket) continue;
error_code e;
i->socket->send_to(asio::buffer(buffer, size), m_multicast_endpoint, 0, e); i->socket->send_to(asio::buffer(buffer, size), m_multicast_endpoint, 0, e);
#ifdef TORRENT_DEBUG
// extern std::string print_address(address const& addr);
// extern std::string print_endpoint(udp::endpoint const& ep);
// fprintf(stderr, " sending on multicast %s to: %s\n", print_address(i->socket->local_endpoint().address()).c_str()
// , print_endpoint(m_multicast_endpoint).c_str());
#endif
if (e) if (e)
{ {
#ifdef TORRENT_DEBUG
// fprintf(stderr, " ERROR: %s\n", e.message().c_str());
#endif
i->socket->close(e); i->socket->close(e);
i->socket.reset(); i->socket.reset();
} }
else
{
all_fail = false;
}
} }
if (all_fail) ec = e;
} }
void broadcast_socket::on_receive(socket_entry* s, error_code const& ec void broadcast_socket::on_receive(socket_entry* s, error_code const& ec

View File

@ -96,7 +96,7 @@ namespace libtorrent
} }
url.replace(pos, 8, "scrape"); url.replace(pos, 8, "scrape");
} }
#if TORRENT_USE_I2P #if TORRENT_USE_I2P
bool i2p = is_i2p_url(url); bool i2p = is_i2p_url(url);
#else #else
@ -113,7 +113,7 @@ namespace libtorrent
url += "&"; url += "&";
else else
url += "?"; url += "?";
if (tracker_req().kind == tracker_request::announce_request) if (tracker_req().kind == tracker_request::announce_request)
{ {
const char* event_string[] = {"completed", "started", "stopped", "paused"}; const char* event_string[] = {"completed", "started", "stopped", "paused"};
@ -251,15 +251,18 @@ namespace libtorrent
tracker_connection::close(); tracker_connection::close();
} }
void http_tracker_connection::on_filter(http_connection& c, std::vector<tcp::endpoint>& endpoints) // endpoints is an in-out parameter
void http_tracker_connection::on_filter(http_connection& c
, std::vector<tcp::endpoint>& endpoints)
{ {
TORRENT_UNUSED(c);
if (!tracker_req().filter) return; if (!tracker_req().filter) return;
// remove endpoints that are filtered by the IP filter // remove endpoints that are filtered by the IP filter
for (std::vector<tcp::endpoint>::iterator i = endpoints.begin(); for (std::vector<tcp::endpoint>::iterator i = endpoints.begin();
i != endpoints.end();) i != endpoints.end();)
{ {
if (tracker_req().filter->access(i->address()) == ip_filter::blocked) if (tracker_req().filter->access(i->address()) == ip_filter::blocked)
i = endpoints.erase(i); i = endpoints.erase(i);
else else
++i; ++i;
@ -295,7 +298,7 @@ namespace libtorrent
fail(ec); fail(ec);
return; return;
} }
if (!parser.header_finished()) if (!parser.header_finished())
{ {
fail(asio::error::eof); fail(asio::error::eof);
@ -308,13 +311,13 @@ namespace libtorrent
, parser.status_code(), parser.message().c_str()); , parser.status_code(), parser.message().c_str());
return; return;
} }
if (ec && ec != asio::error::eof) if (ec && ec != asio::error::eof)
{ {
fail(ec, parser.status_code()); fail(ec, parser.status_code());
return; return;
} }
received_bytes(size + parser.body_start()); received_bytes(size + parser.body_start());
// handle tracker response // handle tracker response
@ -576,7 +579,7 @@ namespace libtorrent
resp.external_ip = detail::read_v6_address(p); resp.external_ip = detail::read_v6_address(p);
#endif #endif
} }
return resp; return resp;
} }
} }

View File

@ -122,14 +122,6 @@ namespace libtorrent { namespace dht
namespace { namespace {
node_id extract_node_id(bdecode_node e)
{
if (!e || e.type() != bdecode_node::dict_t) return (node_id::min)();
bdecode_node nid = e.dict_find_string("node-id");
if (!nid || nid.string_length() != 20) return (node_id::min)();
return node_id(node_id(nid.string_ptr()));
}
node_id extract_node_id(entry const* e) node_id extract_node_id(entry const* e)
{ {
if (e == 0 || e->type() != entry::dictionary_t) return (node_id::min)(); if (e == 0 || e->type() != entry::dictionary_t) return (node_id::min)();

View File

@ -324,7 +324,10 @@ namespace libtorrent
, int& produce , int& produce
, int& packet_size) , int& packet_size)
{ {
// these are out-parameters that are not set
TORRENT_UNUSED(consume); TORRENT_UNUSED(consume);
TORRENT_UNUSED(packet_size);
if (!m_decrypt) return; if (!m_decrypt) return;
int bytes_processed = 0; int bytes_processed = 0;
@ -338,7 +341,7 @@ namespace libtorrent
TORRENT_ASSERT(pos); TORRENT_ASSERT(pos);
bytes_processed += len; bytes_processed += len;
rc4_encrypt((unsigned char*)pos, len, &m_rc4_incoming); rc4_encrypt(reinterpret_cast<unsigned char*>(pos), len, &m_rc4_incoming);
} }
buf.clear(); buf.clear();
produce = bytes_processed; produce = bytes_processed;

View File

@ -248,6 +248,8 @@ void udp_socket::on_writable(error_code const& ec, udp::socket* s)
#endif #endif
m_v4_write_subscribed = false; m_v4_write_subscribed = false;
if (ec == asio::error::operation_aborted) return;
call_writable_handler(); call_writable_handler();
} }

View File

@ -326,6 +326,7 @@ namespace libtorrent
bool udp_tracker_connection::on_receive_hostname(error_code const& e bool udp_tracker_connection::on_receive_hostname(error_code const& e
, char const* hostname, char const* buf, int size) , char const* hostname, char const* buf, int size)
{ {
TORRENT_UNUSED(hostname);
// just ignore the hostname this came from, pretend that // just ignore the hostname this came from, pretend that
// it's from the same endpoint we sent it to (i.e. the same // it's from the same endpoint we sent it to (i.e. the same
// port). We have so many other ways of confirming this packet // port). We have so many other ways of confirming this packet
@ -371,7 +372,7 @@ namespace libtorrent
#endif #endif
return false; return false;
} }
if (e) fail(e); if (e) fail(e);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
@ -449,7 +450,7 @@ namespace libtorrent
m_man.update_transaction_id(shared_from_this(), new_tid); m_man.update_transaction_id(shared_from_this(), new_tid);
m_transaction_id = new_tid; m_transaction_id = new_tid;
} }
bool udp_tracker_connection::on_connect_response(char const* buf, int size) bool udp_tracker_connection::on_connect_response(char const* buf, int size)
{ {
// ignore packets smaller than 16 bytes // ignore packets smaller than 16 bytes

View File

@ -69,7 +69,6 @@ namespace upnp_errors
static error_code ec; static error_code ec;
// TODO: 3 listen_interface is not used. It's meant to bind the broadcast socket
upnp::upnp(io_service& ios upnp::upnp(io_service& ios
, address const& listen_interface, std::string const& user_agent , address const& listen_interface, std::string const& user_agent
, portmap_callback_t const& cb, log_callback_t const& lcb , portmap_callback_t const& cb, log_callback_t const& lcb
@ -90,6 +89,12 @@ upnp::upnp(io_service& ios
, m_last_if_update(min_time()) , m_last_if_update(min_time())
{ {
TORRENT_ASSERT(cb); TORRENT_ASSERT(cb);
// TODO: 3 listen_interface is not used. It's meant to bind the broadcast
// socket. it would probably have to be changed to a vector of interfaces to
// bind to though, since the broadcast socket opens one socket per local
// interface by default
TORRENT_UNUSED(listen_interface);
} }
void upnp::start(void* state) void upnp::start(void* state)

View File

@ -166,6 +166,9 @@ namespace libtorrent
void utp_socket_manager::send_packet(udp::endpoint const& ep, char const* p void utp_socket_manager::send_packet(udp::endpoint const& ep, char const* p
, int len, error_code& ec, int flags) , int len, error_code& ec, int flags)
{ {
#if !defined TORRENT_HAS_DONT_FRAGMENT && !defined TORRENT_DEBUG_MTU
TORRENT_UNUSED(flags);
#endif
if (!m_sock.is_open()) if (!m_sock.is_open())
{ {
ec = asio::error::operation_aborted; ec = asio::error::operation_aborted;
@ -253,6 +256,9 @@ namespace libtorrent
bool utp_socket_manager::incoming_packet(error_code const& ec, udp::endpoint const& ep bool utp_socket_manager::incoming_packet(error_code const& ec, udp::endpoint const& ep
, char const* p, int size) , char const* p, int size)
{ {
// TODO: 2 we may want to take ec into account here. possibly close
// connections quicker
TORRENT_UNUSED(ec);
// UTP_LOGV("incoming packet size:%d\n", size); // UTP_LOGV("incoming packet size:%d\n", size);
if (size < int(sizeof(utp_header))) return false; if (size < int(sizeof(utp_header))) return false;
@ -264,7 +270,7 @@ namespace libtorrent
if (ph->get_version() != 1) return false; if (ph->get_version() != 1) return false;
const time_point receive_time = clock_type::now(); const time_point receive_time = clock_type::now();
// parse out connection ID and look for existing // parse out connection ID and look for existing
// connections. If found, forward to the utp_stream. // connections. If found, forward to the utp_stream.
boost::uint16_t id = ph->connection_id; boost::uint16_t id = ph->connection_id;
@ -363,7 +369,7 @@ namespace libtorrent
void utp_socket_manager::socket_drained() void utp_socket_manager::socket_drained()
{ {
// flush all deferred acks // flush all deferred acks
std::vector<utp_socket_impl*> deferred_acks; std::vector<utp_socket_impl*> deferred_acks;
m_deferred_acks.swap(deferred_acks); m_deferred_acks.swap(deferred_acks);
for (std::vector<utp_socket_impl*>::iterator i = deferred_acks.begin() for (std::vector<utp_socket_impl*>::iterator i = deferred_acks.begin()
@ -405,7 +411,7 @@ namespace libtorrent
if (m_last_socket == i->second) m_last_socket = 0; if (m_last_socket == i->second) m_last_socket = 0;
m_utp_sockets.erase(i); m_utp_sockets.erase(i);
} }
void utp_socket_manager::set_sock_buf(int size) void utp_socket_manager::set_sock_buf(int size)
{ {
if (size < m_sock_buf_size) return; if (size < m_sock_buf_size) return;

View File

@ -3438,7 +3438,7 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
} }
} }
void utp_stream::bind(endpoint_type const& ep, error_code& ec) { } void utp_stream::bind(endpoint_type const&, error_code&) { }
void utp_stream::cancel_handlers(error_code const& ec) void utp_stream::cancel_handlers(error_code const& ec)
{ {