switched over to asio from boost-1.35

This commit is contained in:
Arvid Norberg 2008-05-03 16:05:42 +00:00
parent cb5f783987
commit c7e6c04705
72 changed files with 483 additions and 497 deletions

View File

@ -330,7 +330,6 @@ ZLIB_SOURCES =
local usage-requirements =
<include>./include
<include>./include/libtorrent
<zlib>shipped:<include>./zlib
<variant>release:<define>NDEBUG
<define>_FILE_OFFSET_BITS=64

View File

@ -9,7 +9,7 @@ using namespace libtorrent;
int main()
{
io_service ios;
asio::error_code ec;
error_code ec;
address local = guess_local_address(ios);
std::cout << "Local address: " << local << std::endl;

View File

@ -151,7 +151,7 @@ namespace libtorrent
void async_accept(boost::shared_ptr<socket_acceptor> const& listener);
void on_incoming_connection(boost::shared_ptr<socket_type> const& s
, boost::weak_ptr<socket_acceptor> listener, asio::error_code const& e);
, boost::weak_ptr<socket_acceptor> listener, error_code const& e);
// must be locked to access the data
// in this struct
@ -498,7 +498,7 @@ namespace libtorrent
// NAT or not.
bool m_incoming_connection;
void second_tick(asio::error_code const& e);
void second_tick(error_code const& e);
void recalculate_auto_managed_torrents();
void recalculate_unchoke_slots(int congested_torrents
, int uncongested_torrents);
@ -528,7 +528,7 @@ namespace libtorrent
udp_socket m_dht_socket;
void on_receive_udp(asio::error_code const& e
void on_receive_udp(error_code const& e
, udp::endpoint const& ep, char const* buf, int len);
#endif

View File

@ -256,12 +256,12 @@ private:
if (m_abort) return;
asio::error_code ec;
error_code ec;
m_history_timer.expires_at(e.expires_at, ec);
m_history_timer.async_wait(bind(&bandwidth_manager::on_history_expire, this, _1));
}
void on_history_expire(asio::error_code const& e)
void on_history_expire(error_code const& e)
{
if (e) return;
@ -298,7 +298,7 @@ private:
// now, wait for the next chunk to expire
if (!m_history.empty() && !m_abort)
{
asio::error_code ec;
error_code ec;
m_history_timer.expires_at(m_history.back().expires_at, ec);
m_history_timer.async_wait(bind(&bandwidth_manager::on_history_expire, this, _1));
}

View File

@ -51,7 +51,7 @@ namespace libtorrent
int common_bits(unsigned char const* b1
, unsigned char const* b2, int n);
TORRENT_EXPORT address guess_local_address(asio::io_service&);
TORRENT_EXPORT address guess_local_address(io_service&);
typedef boost::function<void(udp::endpoint const& from
, char* buffer, int size)> receive_handler_t;
@ -59,11 +59,11 @@ namespace libtorrent
class TORRENT_EXPORT broadcast_socket
{
public:
broadcast_socket(asio::io_service& ios, udp::endpoint const& multicast_endpoint
broadcast_socket(io_service& ios, udp::endpoint const& multicast_endpoint
, receive_handler_t const& handler, bool loopback = true);
~broadcast_socket() { close(); }
void send(char const* buffer, int size, asio::error_code& ec);
void send(char const* buffer, int size, error_code& ec);
void close();
private:
@ -77,12 +77,12 @@ namespace libtorrent
void close()
{
if (!socket) return;
asio::error_code ec;
error_code ec;
socket->close(ec);
}
};
void on_receive(socket_entry* s, asio::error_code const& ec
void on_receive(socket_entry* s, error_code const& ec
, std::size_t bytes_transferred);
void open_unicast_socket(io_service& ios, address const& addr);
void open_multicast_socket(io_service& ios, address const& addr

View File

@ -141,9 +141,9 @@ namespace libtorrent
// called from the main loop when this connection has any
// work to do.
void on_sent(asio::error_code const& error
void on_sent(error_code const& error
, std::size_t bytes_transferred);
void on_receive(asio::error_code const& error
void on_receive(error_code const& error
, std::size_t bytes_transferred);
virtual void get_specific_peer_info(peer_info& p) const;

View File

@ -34,12 +34,14 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_CHAINED_BUFFER_HPP_INCLUDED
#include <boost/function.hpp>
#include <asio/buffer.hpp>
#include <boost/asio/buffer.hpp>
#include <list>
#include <cstring>
namespace libtorrent
{
namespace asio = boost::asio;
struct chained_buffer
{
chained_buffer(): m_bytes(0), m_capacity(0) {}

View File

@ -71,7 +71,7 @@ public:
private:
void try_connect();
void on_timeout(asio::error_code const& e);
void on_timeout(error_code const& e);
struct entry
{

View File

@ -149,7 +149,7 @@ namespace libtorrent
// of disk io jobs
struct disk_io_thread : boost::noncopyable
{
disk_io_thread(asio::io_service& ios, int block_size = 16 * 1024);
disk_io_thread(io_service& ios, int block_size = 16 * 1024);
~disk_io_thread();
#ifdef TORRENT_STATS
@ -292,7 +292,7 @@ namespace libtorrent
size_type m_writes;
size_type m_blocks_written;
asio::io_service& m_ios;
io_service& m_ios;
// thread for performing blocking disk io operations
boost::thread m_disk_io_thread;

View File

@ -56,10 +56,10 @@ namespace libtorrent
// returns a list of the configured IP interfaces
// on the machine
TORRENT_EXPORT std::vector<ip_interface> enum_net_interfaces(asio::io_service& ios
, asio::error_code& ec);
TORRENT_EXPORT std::vector<ip_interface> enum_net_interfaces(io_service& ios
, error_code& ec);
TORRENT_EXPORT std::vector<ip_route> enum_routes(asio::io_service& ios, asio::error_code& ec);
TORRENT_EXPORT std::vector<ip_route> enum_routes(io_service& ios, error_code& ec);
// returns true if the specified address is on the same
// local network as the specified interface
@ -67,11 +67,11 @@ namespace libtorrent
// returns true if the specified address is on the same
// local network as us
TORRENT_EXPORT bool in_local_network(asio::io_service& ios, address const& addr
, asio::error_code& ec);
TORRENT_EXPORT bool in_local_network(io_service& ios, address const& addr
, error_code& ec);
TORRENT_EXPORT address get_default_gateway(asio::io_service& ios
, asio::error_code& ec);
TORRENT_EXPORT address get_default_gateway(io_service& ios
, error_code& ec);
}
#endif

View File

@ -59,7 +59,7 @@ namespace libtorrent
struct http_connection;
class connection_queue;
typedef boost::function<void(asio::error_code const&
typedef boost::function<void(error_code const&
, http_parser const&, char const* data, int size)> http_handler;
typedef boost::function<void(http_connection&)> http_connect_handler;
@ -70,7 +70,7 @@ typedef boost::function<void(http_connection&)> http_connect_handler;
// will always be 0
struct http_connection : boost::enable_shared_from_this<http_connection>, boost::noncopyable
{
http_connection(asio::io_service& ios, connection_queue& cc
http_connection(io_service& ios, connection_queue& cc
, http_handler const& handler, bool bottled = true
, http_connect_handler const& ch = http_connect_handler())
: m_sock(ios)
@ -121,19 +121,19 @@ struct http_connection : boost::enable_shared_from_this<http_connection>, boost:
private:
void on_resolve(asio::error_code const& e
void on_resolve(error_code const& e
, tcp::resolver::iterator i);
void connect(int ticket, tcp::endpoint target_address);
void on_connect_timeout();
void on_connect(asio::error_code const& e
void on_connect(error_code const& e
/* , tcp::resolver::iterator i*/);
void on_write(asio::error_code const& e);
void on_read(asio::error_code const& e, std::size_t bytes_transferred);
void on_write(error_code const& e);
void on_read(error_code const& e, std::size_t bytes_transferred);
static void on_timeout(boost::weak_ptr<http_connection> p
, asio::error_code const& e);
void on_assign_bandwidth(asio::error_code const& e);
, error_code const& e);
void on_assign_bandwidth(error_code const& e);
void callback(asio::error_code const& e, char const* data = 0, int size = 0);
void callback(error_code const& e, char const* data = 0, int size = 0);
std::vector<char> m_recvbuffer;
#ifdef TORRENT_USE_OPENSSL

View File

@ -41,7 +41,7 @@ class http_stream : public proxy_base
{
public:
explicit http_stream(asio::io_service& io_service)
explicit http_stream(io_service& io_service)
: proxy_base(io_service)
, m_no_connect(false)
{}
@ -55,7 +55,7 @@ public:
m_password = password;
}
typedef boost::function<void(asio::error_code const&)> handler_type;
typedef boost::function<void(error_code const&)> handler_type;
template <class Handler>
void async_connect(endpoint_type const& endpoint, Handler const& handler)
@ -80,11 +80,11 @@ public:
private:
void name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void name_lookup(error_code const& e, tcp::resolver::iterator i
, boost::shared_ptr<handler_type> h);
void connected(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void connected(error_code const& e, boost::shared_ptr<handler_type> h);
void handshake1(error_code const& e, boost::shared_ptr<handler_type> h);
void handshake2(error_code const& e, boost::shared_ptr<handler_type> h);
// send and receive buffer
std::vector<char> m_buffer;

View File

@ -82,7 +82,7 @@ namespace libtorrent
boost::intrusive_ptr<http_tracker_connection> self()
{ return boost::intrusive_ptr<http_tracker_connection>(this); }
void on_response(asio::error_code const& ec, http_parser const& parser
void on_response(error_code const& ec, http_parser const& parser
, char const* data, int size);
virtual void on_timeout() {}

View File

@ -34,14 +34,13 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_INSTANTIATE_CONNECTION
#include "libtorrent/socket_type.hpp"
#include <asio/io_service.hpp>
#include <boost/shared_ptr.hpp>
namespace libtorrent
{
struct proxy_settings;
bool instantiate_connection(asio::io_service& ios
bool instantiate_connection(io_service& ios
, proxy_settings const& ps, socket_type& s);
}

View File

@ -68,7 +68,7 @@ public:
private:
void done();
void invoke(node_id const& id, asio::ip::udp::endpoint addr);
void invoke(node_id const& id, udp::endpoint addr);
closest_nodes(
node_id target

View File

@ -53,6 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_settings.hpp"
#include "libtorrent/session_status.hpp"
#include "libtorrent/udp_socket.hpp"
#include "libtorrent/socket.hpp"
namespace libtorrent { namespace dht
{
@ -95,13 +96,13 @@ namespace libtorrent { namespace dht
boost::intrusive_ptr<dht_tracker> self()
{ return boost::intrusive_ptr<dht_tracker>(this); }
void on_name_lookup(asio::error_code const& e
void on_name_lookup(error_code const& e
, udp::resolver::iterator host);
void on_router_name_lookup(asio::error_code const& e
void on_router_name_lookup(error_code const& e
, udp::resolver::iterator host);
void connection_timeout(asio::error_code const& e);
void refresh_timeout(asio::error_code const& e);
void tick(asio::error_code const& e);
void connection_timeout(error_code const& e);
void refresh_timeout(error_code const& e);
void tick(error_code const& e);
void on_bootstrap();
void send_packet(msg const& m);

View File

@ -48,8 +48,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
using asio::ip::udp;
typedef std::vector<char> packet_t;
class rpc_manager;

View File

@ -36,15 +36,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include <libtorrent/kademlia/node_id.hpp>
#include "libtorrent/entry.hpp"
#include <asio/ip/udp.hpp>
#include <boost/asio/ip/udp.hpp>
namespace libtorrent {
namespace dht {
typedef std::vector<char> packet_t;
using asio::ip::udp;
namespace messages
{
enum { ping = 0, find_node = 1, get_peers = 2, announce_peer = 3, error = 4 };

View File

@ -56,8 +56,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
using asio::ip::udp;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_DECLARE_LOG(node);
#endif

View File

@ -41,11 +41,11 @@ namespace libtorrent { namespace dht
struct node_entry
{
node_entry(node_id const& id_, asio::ip::udp::endpoint addr_)
node_entry(node_id const& id_, udp::endpoint addr_)
: id(id_)
, addr(addr_)
, fail_count(0) {}
node_entry(asio::ip::udp::endpoint addr_)
node_entry(udp::endpoint addr_)
: id(0)
, addr(addr_)
, fail_count(0) {}

View File

@ -55,8 +55,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
using asio::ip::udp;
//TORRENT_DECLARE_LOG(table);
typedef std::vector<node_entry> bucket_t;

View File

@ -56,7 +56,6 @@ namespace libtorrent { namespace dht
struct observer;
using asio::ip::udp;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_DECLARE_LOG(rpc);
#endif

View File

@ -67,7 +67,7 @@ public:
private:
void resend_announce(asio::error_code const& e, std::string msg);
void resend_announce(error_code const& e, std::string msg);
void on_announce(udp::endpoint const& from, char* buffer
, std::size_t bytes_transferred);
// void setup_receive();

View File

@ -70,12 +70,12 @@ private:
void update_mapping(int i);
void send_map_request(int i);
void resend_request(int i, asio::error_code const& e);
void on_reply(asio::error_code const& e
void resend_request(int i, error_code const& e);
void on_reply(error_code const& e
, std::size_t bytes_transferred);
void try_next_mapping(int i);
void update_expiration_timer();
void mapping_expired(asio::error_code const& e, int i);
void mapping_expired(error_code const& e, int i);
void disable(char const* message);

View File

@ -248,7 +248,7 @@ namespace libtorrent
// this is called when the connection attempt has succeeded
// and the peer_connection is supposed to set m_connecting
// to false, and stop monitor writability
void on_connection_complete(asio::error_code const& e);
void on_connection_complete(error_code const& e);
// returns true if this connection is still waiting to
// finish the connection attempt
@ -449,9 +449,9 @@ namespace libtorrent
virtual void on_connected() = 0;
virtual void on_tick() {}
virtual void on_receive(asio::error_code const& error
virtual void on_receive(error_code const& error
, std::size_t bytes_transferred) = 0;
virtual void on_sent(asio::error_code const& error
virtual void on_sent(error_code const& error
, std::size_t bytes_transferred) = 0;
#ifndef TORRENT_DISABLE_ENCRYPTION
@ -501,9 +501,9 @@ namespace libtorrent
// called from the main loop when this connection has any
// work to do.
void on_send_data(asio::error_code const& error
void on_send_data(error_code const& error
, std::size_t bytes_transferred);
void on_receive_data(asio::error_code const& error
void on_receive_data(error_code const& error
, std::size_t bytes_transferred);
// this is the limit on the number of outstanding requests

View File

@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/function.hpp>
#include <asio/read.hpp>
#include <asio/write.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/write.hpp>
namespace libtorrent {
@ -52,7 +52,7 @@ public:
typedef stream_socket::endpoint_type endpoint_type;
typedef stream_socket::protocol_type protocol_type;
explicit proxy_base(asio::io_service& io_service)
explicit proxy_base(io_service& io_service)
: m_sock(io_service)
, m_resolver(io_service)
{}
@ -70,7 +70,7 @@ public:
}
template <class Mutable_Buffers>
std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec)
std::size_t read_some(Mutable_Buffers const& buffers, error_code& ec)
{
return m_sock.read_some(buffers, ec);
}
@ -90,7 +90,7 @@ public:
#endif
template <class IO_Control_Command>
void io_control(IO_Control_Command& ioc, asio::error_code& ec)
void io_control(IO_Control_Command& ioc, error_code& ec)
{
m_sock.io_control(ioc, ec);
}
@ -110,7 +110,7 @@ public:
#endif
template <class SettableSocketOption>
asio::error_code set_option(SettableSocketOption const& opt, asio::error_code& ec)
error_code set_option(SettableSocketOption const& opt, error_code& ec)
{
return m_sock.set_option(opt, ec);
}
@ -122,7 +122,7 @@ public:
}
#endif
void bind(endpoint_type const& endpoint, asio::error_code& ec)
void bind(endpoint_type const& endpoint, error_code& ec)
{
m_sock.bind(endpoint, ec);
}
@ -134,7 +134,7 @@ public:
}
#endif
void open(protocol_type const& p, asio::error_code& ec)
void open(protocol_type const& p, error_code& ec)
{
m_sock.open(p, ec);
}
@ -148,7 +148,7 @@ public:
}
#endif
void close(asio::error_code& ec)
void close(error_code& ec)
{
m_sock.close(ec);
m_resolver.cancel();
@ -161,7 +161,7 @@ public:
}
#endif
endpoint_type remote_endpoint(asio::error_code& ec) const
endpoint_type remote_endpoint(error_code& ec) const
{
return m_remote_endpoint;
}
@ -173,14 +173,14 @@ public:
}
#endif
endpoint_type local_endpoint(asio::error_code& ec) const
endpoint_type local_endpoint(error_code& ec) const
{
return m_sock.local_endpoint(ec);
}
asio::io_service& io_service()
io_service& get_io_service()
{
return m_sock.io_service();
return m_sock.get_io_service();
}
lowest_layer_type& lowest_layer()

View File

@ -45,13 +45,15 @@ POSSIBILITY OF SUCH DAMAGE.
#define Protocol Protocol_
#endif
#include <asio/ip/tcp.hpp>
#include <asio/ip/udp.hpp>
#include <asio/io_service.hpp>
#include <asio/deadline_timer.hpp>
#include <asio/write.hpp>
#include <asio/time_traits.hpp>
#include <asio/basic_deadline_timer.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/time_traits.hpp>
#include <boost/asio/basic_deadline_timer.hpp>
#include <boost/system/error_code.hpp>
#ifdef __OBJC__
#undef Protocol
@ -83,23 +85,27 @@ namespace libtorrent
*/
// namespace asio = ::asio;
using asio::ip::tcp;
using asio::ip::udp;
typedef asio::ip::tcp::socket stream_socket;
typedef asio::ip::address address;
typedef asio::ip::address_v4 address_v4;
typedef asio::ip::address_v6 address_v6;
typedef asio::ip::udp::socket datagram_socket;
typedef asio::ip::tcp::acceptor socket_acceptor;
typedef asio::io_service io_service;
using boost::system::error_code;
using boost::asio::ip::tcp;
using boost::asio::ip::udp;
using boost::asio::async_write;
using boost::asio::async_read;
using asio::async_write;
typedef boost::asio::ip::tcp::socket stream_socket;
typedef boost::asio::ip::address address;
typedef boost::asio::ip::address_v4 address_v4;
typedef boost::asio::ip::address_v6 address_v6;
typedef boost::asio::ip::udp::socket datagram_socket;
typedef boost::asio::ip::tcp::acceptor socket_acceptor;
typedef boost::asio::io_service io_service;
namespace asio = boost::asio;
typedef asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
typedef boost::asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
inline std::ostream& print_address(std::ostream& os, address const& addr)
{
asio::error_code ec;
error_code ec;
std::string a = addr.to_string(ec);
if (ec) return os;
os << a;
@ -109,7 +115,7 @@ namespace libtorrent
inline std::ostream& print_endpoint(std::ostream& os, tcp::endpoint const& ep)
{
address const& addr = ep.address();
asio::error_code ec;
error_code ec;
std::string a = addr.to_string(ec);
if (ec) return os;
@ -132,7 +138,7 @@ namespace libtorrent
}
else if (a.is_v6())
{
asio::ip::address_v6::bytes_type bytes
address_v6::bytes_type bytes
= a.to_v6().to_bytes();
std::copy(bytes.begin(), bytes.end(), out);
}
@ -142,18 +148,18 @@ namespace libtorrent
address read_v4_address(InIt& in)
{
unsigned long ip = read_uint32(in);
return asio::ip::address_v4(ip);
return address_v4(ip);
}
template<class InIt>
address read_v6_address(InIt& in)
{
typedef asio::ip::address_v6::bytes_type bytes_t;
typedef address_v6::bytes_type bytes_t;
bytes_t bytes;
for (bytes_t::iterator i = bytes.begin()
, end(bytes.end()); i != end; ++i)
*i = read_uint8(in);
return asio::ip::address_v6(bytes);
return address_v6(bytes);
}
template<class Endpoint, class OutIt>

View File

@ -41,8 +41,8 @@ class socks4_stream : public proxy_base
{
public:
explicit socks4_stream(asio::io_service& io_service)
: proxy_base(io_service)
explicit socks4_stream(io_service& io_service_)
: proxy_base(io_service_)
{}
void set_username(std::string const& user)
@ -50,7 +50,7 @@ public:
m_user = user;
}
typedef boost::function<void(asio::error_code const&)> handler_type;
typedef boost::function<void(error_code const&)> handler_type;
template <class Handler>
void async_connect(endpoint_type const& endpoint, Handler const& handler)
@ -74,11 +74,11 @@ public:
private:
void name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void name_lookup(error_code const& e, tcp::resolver::iterator i
, boost::shared_ptr<handler_type> h);
void connected(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void connected(error_code const& e, boost::shared_ptr<handler_type> h);
void handshake1(error_code const& e, boost::shared_ptr<handler_type> h);
void handshake2(error_code const& e, boost::shared_ptr<handler_type> h);
// send and receive buffer
std::vector<char> m_buffer;

View File

@ -41,7 +41,7 @@ class socks5_stream : public proxy_base
{
public:
explicit socks5_stream(asio::io_service& io_service)
explicit socks5_stream(io_service& io_service)
: proxy_base(io_service)
{}
@ -52,7 +52,7 @@ public:
m_password = password;
}
typedef boost::function<void(asio::error_code const&)> handler_type;
typedef boost::function<void(error_code const&)> handler_type;
template <class Handler>
void async_connect(endpoint_type const& endpoint, Handler const& handler)
@ -79,17 +79,17 @@ public:
private:
void name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void name_lookup(error_code const& e, tcp::resolver::iterator i
, boost::shared_ptr<handler_type> h);
void connected(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void handshake3(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void handshake4(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void connected(error_code const& e, boost::shared_ptr<handler_type> h);
void handshake1(error_code const& e, boost::shared_ptr<handler_type> h);
void handshake2(error_code const& e, boost::shared_ptr<handler_type> h);
void handshake3(error_code const& e, boost::shared_ptr<handler_type> h);
void handshake4(error_code const& e, boost::shared_ptr<handler_type> h);
void socks_connect(boost::shared_ptr<handler_type> h);
void connect1(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void connect2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void connect3(asio::error_code const& e, boost::shared_ptr<handler_type> h);
void connect1(error_code const& e, boost::shared_ptr<handler_type> h);
void connect2(error_code const& e, boost::shared_ptr<handler_type> h);
void connect3(error_code const& e, boost::shared_ptr<handler_type> h);
// send and receive buffer
std::vector<char> m_buffer;

View File

@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_SSL_STREAM_HPP_INCLUDED
#include "libtorrent/socket.hpp"
#include <asio/ssl.hpp>
#include <boost/asio/ssl.hpp>
// openssl seems to believe it owns
// this name in every single scope
@ -47,7 +47,7 @@ class ssl_stream
{
public:
explicit ssl_stream(asio::io_service& io_service)
explicit ssl_stream(io_service& io_service)
: m_context(io_service, asio::ssl::context::sslv23_client)
, m_sock(io_service, m_context)
{
@ -60,7 +60,7 @@ public:
typedef typename Stream::protocol_type protocol_type;
typedef typename asio::ssl::stream<Stream> sock_type;
typedef boost::function<void(asio::error_code const&)> handler_type;
typedef boost::function<void(error_code const&)> handler_type;
template <class Handler>
void async_connect(endpoint_type const& endpoint, Handler const& handler)
@ -70,7 +70,7 @@ public:
// 2. perform SSL client handshake
// to avoid unnecessary copying of the handler,
// store it in a shaed_ptr
// store it in a shared_ptr
boost::shared_ptr<handler_type> h(new handler_type(handler));
m_sock.next_layer().async_connect(endpoint
@ -84,7 +84,7 @@ public:
}
template <class Mutable_Buffers>
std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec)
std::size_t read_some(Mutable_Buffers const& buffers, error_code& ec)
{
return m_sock.read_some(buffers, ec);
}
@ -104,7 +104,7 @@ public:
#endif
template <class IO_Control_Command>
void io_control(IO_Control_Command& ioc, asio::error_code& ec)
void io_control(IO_Control_Command& ioc, error_code& ec)
{
m_sock.next_layer().io_control(ioc, ec);
}
@ -122,7 +122,7 @@ public:
}
#endif
void bind(endpoint_type const& endpoint, asio::error_code& ec)
void bind(endpoint_type const& endpoint, error_code& ec)
{
m_sock.next_layer().bind(endpoint, ec);
}
@ -134,7 +134,7 @@ public:
}
#endif
void open(protocol_type const& p, asio::error_code& ec)
void open(protocol_type const& p, error_code& ec)
{
m_sock.next_layer().open(p, ec);
}
@ -151,7 +151,7 @@ public:
}
#endif
void close(asio::error_code& ec)
void close(error_code& ec)
{
m_sock.next_layer().close(ec);
}
@ -163,7 +163,7 @@ public:
}
#endif
endpoint_type remote_endpoint(asio::error_code& ec) const
endpoint_type remote_endpoint(error_code& ec) const
{
return const_cast<sock_type&>(m_sock).next_layer().remote_endpoint(ec);
}
@ -175,14 +175,14 @@ public:
}
#endif
endpoint_type local_endpoint(asio::error_code& ec) const
endpoint_type local_endpoint(error_code& ec) const
{
return const_cast<sock_type&>(m_sock).next_layer().local_endpoint(ec);
}
asio::io_service& io_service()
io_service& get_io_service()
{
return m_sock.io_service();
return m_sock.get_io_service();
}
lowest_layer_type& lowest_layer()
@ -197,7 +197,7 @@ public:
private:
void connected(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void connected(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
@ -209,7 +209,7 @@ private:
, boost::bind(&ssl_stream::handshake, this, _1, h));
}
void handshake(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void handshake(error_code const& e, boost::shared_ptr<handler_type> h)
{
(*h)(e);
}

View File

@ -86,7 +86,7 @@ namespace libtorrent
#else
#include <asio/time_traits.hpp>
#include <boost/asio/time_traits.hpp>
#include <boost/cstdint.hpp>
#include "libtorrent/assert.hpp"
@ -152,7 +152,7 @@ namespace libtorrent
}
// asio time_traits
namespace asio
namespace boost { namespace asio
{
template<>
struct time_traits<libtorrent::ptime>
@ -171,7 +171,7 @@ namespace asio
duration_type d)
{ return boost::posix_time::microseconds(libtorrent::total_microseconds(d)); }
};
}
} }
#if defined(__MACH__)

View File

@ -461,17 +461,17 @@ namespace libtorrent
// this is the asio callback that is called when a name
// lookup for a PEER is completed.
void on_peer_name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void on_peer_name_lookup(error_code const& e, tcp::resolver::iterator i
, peer_id pid);
// this is the asio callback that is called when a name
// lookup for a WEB SEED is completed.
void on_name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void on_name_lookup(error_code const& e, tcp::resolver::iterator i
, std::string url, tcp::endpoint proxy);
// this is the asio callback that is called when a name
// lookup for a proxy for a web seed is completed.
void on_proxy_name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void on_proxy_name_lookup(error_code const& e, tcp::resolver::iterator i
, std::string url);
// this is called when the torrent has finished. i.e.
@ -587,7 +587,7 @@ namespace libtorrent
void try_next_tracker();
int prioritize_tracker(int tracker_index);
void on_country_lookup(asio::error_code const& error, tcp::resolver::iterator i
void on_country_lookup(error_code const& error, tcp::resolver::iterator i
, boost::intrusive_ptr<peer_connection> p) const;
bool request_bandwidth_from_session(int channel) const;
@ -702,7 +702,7 @@ namespace libtorrent
deadline_timer m_announce_timer;
static void on_announce_disp(boost::weak_ptr<torrent> p
, asio::error_code const& e);
, error_code const& e);
// this is called once per announce interval
void on_announce();

View File

@ -160,7 +160,7 @@ namespace libtorrent
private:
void timeout_callback(asio::error_code const&);
void timeout_callback(error_code const&);
boost::intrusive_ptr<timeout_handler> self()
{ return boost::intrusive_ptr<timeout_handler>(this); }

View File

@ -46,16 +46,16 @@ namespace libtorrent
class udp_socket
{
public:
typedef boost::function<void(asio::error_code const& ec
typedef boost::function<void(error_code const& ec
, udp::endpoint const&, char const* buf, int size)> callback_t;
udp_socket(asio::io_service& ios, callback_t const& c, connection_queue& cc);
udp_socket(io_service& ios, callback_t const& c, connection_queue& cc);
bool is_open() const { return m_ipv4_sock.is_open() || m_ipv6_sock.is_open(); }
asio::io_service& get_io_service() { return m_ipv4_sock.get_io_service(); }
io_service& get_io_service() { return m_ipv4_sock.get_io_service(); }
void send(udp::endpoint const& ep, char const* p, int len, asio::error_code& ec);
void bind(udp::endpoint const& ep, asio::error_code& ec);
void send(udp::endpoint const& ep, char const* p, int len, error_code& ec);
void bind(udp::endpoint const& ep, error_code& ec);
void bind(int port);
void close();
int local_port() const { return m_bind_port; }
@ -67,21 +67,21 @@ namespace libtorrent
callback_t m_callback;
void on_read(udp::socket* sock, asio::error_code const& e, std::size_t bytes_transferred);
void on_name_lookup(asio::error_code const& e, tcp::resolver::iterator i);
void on_read(udp::socket* sock, error_code const& e, std::size_t bytes_transferred);
void on_name_lookup(error_code const& e, tcp::resolver::iterator i);
void on_timeout();
void on_connect(int ticket);
void on_connected(asio::error_code const& ec);
void handshake1(asio::error_code const& e);
void handshake2(asio::error_code const& e);
void handshake3(asio::error_code const& e);
void handshake4(asio::error_code const& e);
void on_connected(error_code const& ec);
void handshake1(error_code const& e);
void handshake2(error_code const& e);
void handshake3(error_code const& e);
void handshake4(error_code const& e);
void socks_forward_udp();
void connect1(asio::error_code const& e);
void connect2(asio::error_code const& e);
void connect1(error_code const& e);
void connect2(error_code const& e);
void wrap(udp::endpoint const& ep, char const* p, int len, asio::error_code& ec);
void unwrap(asio::error_code const& e, char const* buf, int size);
void wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec);
void unwrap(error_code const& e, char const* buf, int size);
udp::socket m_ipv4_sock;
udp::socket m_ipv6_sock;

View File

@ -89,10 +89,10 @@ namespace libtorrent
boost::intrusive_ptr<udp_tracker_connection> self()
{ return boost::intrusive_ptr<udp_tracker_connection>(this); }
void name_lookup(asio::error_code const& error, udp::resolver::iterator i);
void timeout(asio::error_code const& error);
void name_lookup(error_code const& error, udp::resolver::iterator i);
void timeout(error_code const& error);
void on_receive(asio::error_code const& e, udp::endpoint const& ep
void on_receive(error_code const& e, udp::endpoint const& ep
, char const* buf, int size);
void on_connect_response(char const* buf, int size);
void on_announce_response(char const* buf, int size);

View File

@ -93,7 +93,7 @@ private:
enum { default_lease_time = 3600 };
void resend_request(asio::error_code const& e);
void resend_request(error_code const& e);
void on_reply(udp::endpoint const& from, char* buffer
, std::size_t bytes_transferred);
@ -102,15 +102,15 @@ private:
void update_map(rootdevice& d, int i);
void on_upnp_xml(asio::error_code const& e
void on_upnp_xml(error_code const& e
, libtorrent::http_parser const& p, rootdevice& d);
void on_upnp_map_response(asio::error_code const& e
void on_upnp_map_response(error_code const& e
, libtorrent::http_parser const& p, rootdevice& d
, int mapping);
void on_upnp_unmap_response(asio::error_code const& e
void on_upnp_unmap_response(error_code const& e
, libtorrent::http_parser const& p, rootdevice& d
, int mapping);
void on_expire(asio::error_code const& e);
void on_expire(error_code const& e);
void disable(char const* msg);
void return_error(int mapping, int code);
@ -237,7 +237,7 @@ private:
// current retry count
int m_retry_count;
asio::io_service& m_io_service;
io_service& m_io_service;
// the udp socket used to send and receive
// multicast messages on the network

View File

@ -21,7 +21,7 @@
# include <boost/type_traits/add_pointer.hpp>
# include <boost/noncopyable.hpp>
#include <asio/io_service.hpp>
#include <boost/asio/io_service.hpp>
# define NETWORK_VARIANT_STREAM_LIMIT 5
@ -48,7 +48,7 @@ namespace aux
template<class IO_Control_Command>
struct io_control_visitor_ec: boost::static_visitor<>
{
io_control_visitor_ec(IO_Control_Command& ioc, asio::error_code& ec_)
io_control_visitor_ec(IO_Control_Command& ioc, error_code& ec_)
: ioc(ioc), ec(ec_) {}
template <class T>
@ -61,7 +61,7 @@ namespace aux
{}
IO_Control_Command& ioc;
asio::error_code& ec;
error_code& ec;
};
template<class IO_Control_Command>
@ -112,7 +112,7 @@ namespace aux
struct bind_visitor_ec
: boost::static_visitor<>
{
bind_visitor_ec(EndpointType const& ep, asio::error_code& ec_)
bind_visitor_ec(EndpointType const& ep, error_code& ec_)
: endpoint(ep)
, ec(ec_)
{}
@ -124,7 +124,7 @@ namespace aux
void operator()(boost::blank) const {}
EndpointType const& endpoint;
asio::error_code& ec;
error_code& ec;
};
template <class EndpointType>
@ -150,7 +150,7 @@ namespace aux
struct open_visitor_ec
: boost::static_visitor<>
{
open_visitor_ec(Protocol const& p, asio::error_code& ec_)
open_visitor_ec(Protocol const& p, error_code& ec_)
: proto(p)
, ec(ec_)
{}
@ -162,7 +162,7 @@ namespace aux
void operator()(boost::blank) const {}
Protocol const& proto;
asio::error_code& ec;
error_code& ec;
};
template <class Protocol>
@ -201,7 +201,7 @@ namespace aux
struct close_visitor_ec
: boost::static_visitor<>
{
close_visitor_ec(asio::error_code& ec_)
close_visitor_ec(error_code& ec_)
: ec(ec_)
{}
@ -211,7 +211,7 @@ namespace aux
void operator()(boost::blank) const {}
asio::error_code& ec;
error_code& ec;
};
struct close_visitor
@ -230,18 +230,18 @@ namespace aux
struct remote_endpoint_visitor_ec
: boost::static_visitor<EndpointType>
{
remote_endpoint_visitor_ec(asio::error_code& ec)
: error_code(ec)
remote_endpoint_visitor_ec(error_code& ec_)
: ec(ec_)
{}
template <class T>
EndpointType operator()(T const* p) const
{ return p->remote_endpoint(error_code); }
{ return p->remote_endpoint(ec); }
EndpointType operator()(boost::blank) const
{ return EndpointType(); }
asio::error_code& error_code;
error_code& ec;
};
template <class EndpointType>
@ -270,29 +270,29 @@ namespace aux
void operator()(T* p) const
{ p->set_option(opt_); }
void operator()(boost::blank) const {}
void operator()(boost::blank) const {}
SettableSocketOption const& opt_;
};
template <class SettableSocketOption>
struct set_option_visitor_ec
: boost::static_visitor<asio::error_code>
: boost::static_visitor<error_code>
{
set_option_visitor_ec(SettableSocketOption const& opt, asio::error_code& ec)
set_option_visitor_ec(SettableSocketOption const& opt, error_code& ec)
: opt_(opt)
, ec_(ec)
{}
template <class T>
asio::error_code operator()(T* p) const
error_code operator()(T* p) const
{ return p->set_option(opt_, ec_); }
asio::error_code operator()(boost::blank) const
error_code operator()(boost::blank) const
{ return ec_; }
SettableSocketOption const& opt_;
asio::error_code& ec_;
error_code& ec_;
};
// -------------- local_endpoint -----------
@ -301,14 +301,14 @@ namespace aux
struct local_endpoint_visitor_ec
: boost::static_visitor<EndpointType>
{
local_endpoint_visitor_ec(asio::error_code& ec)
: error_code(ec)
local_endpoint_visitor_ec(error_code& ec_)
: ec(ec_)
{}
template <class T>
EndpointType operator()(T const* p) const
{
return p->local_endpoint(error_code);
return p->local_endpoint(ec);
}
EndpointType operator()(boost::blank) const
@ -316,7 +316,7 @@ namespace aux
return EndpointType();
}
asio::error_code& error_code;
error_code& ec;
};
template <class EndpointType>
@ -372,7 +372,7 @@ namespace aux
std::size_t operator()(T* p) const
{ return p->read_some(buffers); }
std::size_t operator()(boost::blank) const
std::size_t operator()(boost::blank) const
{ return 0; }
Mutable_Buffers const& buffers;
@ -382,7 +382,7 @@ namespace aux
struct read_some_visitor_ec
: boost::static_visitor<std::size_t>
{
read_some_visitor_ec(Mutable_Buffers const& buffers, asio::error_code& ec_)
read_some_visitor_ec(Mutable_Buffers const& buffers, error_code& ec_)
: buffers(buffers)
, ec(ec_)
{}
@ -391,11 +391,11 @@ namespace aux
std::size_t operator()(T* p) const
{ return p->read_some(buffers, ec); }
std::size_t operator()(boost::blank) const
std::size_t operator()(boost::blank) const
{ return 0; }
Mutable_Buffers const& buffers;
asio::error_code& ec;
error_code& ec;
};
// -------------- async_write_some -----------
@ -427,7 +427,7 @@ namespace aux
struct in_avail_visitor_ec
: boost::static_visitor<std::size_t>
{
in_avail_visitor_ec(asio::error_code& ec_)
in_avail_visitor_ec(error_code& ec_)
: ec(ec_)
{}
@ -442,7 +442,7 @@ namespace aux
return 0;
}
asio::error_code& ec;
error_code& ec;
};
struct in_avail_visitor
@ -524,11 +524,11 @@ public:
typedef typename S0::endpoint_type endpoint_type;
typedef typename S0::protocol_type protocol_type;
explicit variant_stream(asio::io_service& ios)
explicit variant_stream(io_service& ios)
: m_io_service(ios), m_variant(boost::blank()) {}
template <class S>
void instantiate(asio::io_service& ios)
void instantiate(io_service& ios)
{
TORRENT_ASSERT(&ios == &m_io_service);
std::auto_ptr<S> owned(new S(ios));
@ -540,7 +540,7 @@ public:
template <class S>
S& get()
{
return *boost::get<S*>(m_variant);
return *boost::get<S*>(m_variant);
}
bool instantiated() const
@ -554,7 +554,7 @@ public:
}
template <class Mutable_Buffers>
std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec)
std::size_t read_some(Mutable_Buffers const& buffers, error_code& ec)
{
TORRENT_ASSERT(instantiated());
return boost::apply_visitor(
@ -612,7 +612,7 @@ public:
}
template <class IO_Control_Command>
void io_control(IO_Control_Command& ioc, asio::error_code& ec)
void io_control(IO_Control_Command& ioc, error_code& ec)
{
TORRENT_ASSERT(instantiated());
boost::apply_visitor(
@ -627,7 +627,7 @@ public:
boost::apply_visitor(aux::bind_visitor<endpoint_type>(endpoint), m_variant);
}
void bind(endpoint_type const& endpoint, asio::error_code& ec)
void bind(endpoint_type const& endpoint, error_code& ec)
{
TORRENT_ASSERT(instantiated());
boost::apply_visitor(
@ -641,7 +641,7 @@ public:
boost::apply_visitor(aux::open_visitor<protocol_type>(p), m_variant);
}
void open(protocol_type const& p, asio::error_code& ec)
void open(protocol_type const& p, error_code& ec)
{
TORRENT_ASSERT(instantiated());
boost::apply_visitor(
@ -660,7 +660,7 @@ public:
boost::apply_visitor(aux::close_visitor(), m_variant);
}
void close(asio::error_code& ec)
void close(error_code& ec)
{
if (!instantiated()) return;
boost::apply_visitor(
@ -674,7 +674,7 @@ public:
return boost::apply_visitor(aux::in_avail_visitor(), m_variant);
}
std::size_t in_avail(asio::error_code& ec) const
std::size_t in_avail(error_code& ec) const
{
TORRENT_ASSERT(instantiated());
return boost::apply_visitor(
@ -688,7 +688,7 @@ public:
return boost::apply_visitor(aux::remote_endpoint_visitor<endpoint_type>(), m_variant);
}
endpoint_type remote_endpoint(asio::error_code& ec) const
endpoint_type remote_endpoint(error_code& ec) const
{
TORRENT_ASSERT(instantiated());
return boost::apply_visitor(
@ -705,20 +705,20 @@ public:
}
template <class SettableSocketOption>
asio::error_code set_option(SettableSocketOption const& opt, asio::error_code& ec)
error_code set_option(SettableSocketOption const& opt, error_code& ec)
{
TORRENT_ASSERT(instantiated());
return boost::apply_visitor(aux::set_option_visitor_ec<SettableSocketOption>(opt, ec)
, m_variant);
}
endpoint_type local_endpoint() const
{
TORRENT_ASSERT(instantiated());
return boost::apply_visitor(aux::local_endpoint_visitor<endpoint_type>(), m_variant);
}
endpoint_type local_endpoint(asio::error_code& ec) const
endpoint_type local_endpoint(error_code& ec) const
{
TORRENT_ASSERT(instantiated());
return boost::apply_visitor(
@ -726,7 +726,7 @@ public:
);
}
asio::io_service& get_io_service()
io_service& get_io_service()
{
return m_io_service;
}
@ -740,7 +740,7 @@ public:
}
private:
asio::io_service& m_io_service;
io_service& m_io_service;
variant_type m_variant;
};

View File

@ -102,9 +102,9 @@ namespace libtorrent
// called from the main loop when this connection has any
// work to do.
void on_sent(asio::error_code const& error
void on_sent(error_code const& error
, std::size_t bytes_transferred);
void on_receive(asio::error_code const& error
void on_receive(error_code const& error
, std::size_t bytes_transferred);
std::string const& url() const { return m_url; }

View File

@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include <asio/ip/host_name.hpp>
#include <asio/ip/multicast.hpp>
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/ip/multicast.hpp>
#include <boost/bind.hpp>
#include "libtorrent/socket.hpp"
@ -75,10 +75,10 @@ namespace libtorrent
return addr.to_v6() == address_v6::any();
}
address guess_local_address(asio::io_service& ios)
address guess_local_address(io_service& ios)
{
// make a best guess of the interface we're using and its IP
asio::error_code ec;
error_code ec;
std::vector<ip_interface> const& interfaces = enum_net_interfaces(ios, ec);
address ret = address_v4::any();
for (std::vector<ip_interface>::const_iterator i = interfaces.begin()
@ -137,7 +137,7 @@ namespace libtorrent
- common_bits(b1.c_array(), b2.c_array(), b1.size());
}
broadcast_socket::broadcast_socket(asio::io_service& ios
broadcast_socket::broadcast_socket(io_service& ios
, udp::endpoint const& multicast_endpoint
, receive_handler_t const& handler
, bool loopback)
@ -148,7 +148,7 @@ namespace libtorrent
using namespace asio::ip::multicast;
asio::error_code ec;
error_code ec;
std::vector<ip_interface> interfaces = enum_net_interfaces(ios, ec);
if (multicast_endpoint.address().is_v4())
@ -179,7 +179,7 @@ namespace libtorrent
{
using namespace asio::ip::multicast;
asio::error_code ec;
error_code ec;
boost::shared_ptr<datagram_socket> s(new datagram_socket(ios));
if (addr.is_v4())
s->open(udp::v4(), ec);
@ -205,7 +205,7 @@ namespace libtorrent
void broadcast_socket::open_unicast_socket(io_service& ios, address const& addr)
{
using namespace asio::ip::multicast;
asio::error_code ec;
error_code ec;
boost::shared_ptr<datagram_socket> s(new datagram_socket(ios));
s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec);
if (ec) return;
@ -220,13 +220,13 @@ namespace libtorrent
, se.remote, bind(&broadcast_socket::on_receive, this, &se, _1, _2));
}
void broadcast_socket::send(char const* buffer, int size, asio::error_code& ec)
void broadcast_socket::send(char const* buffer, int size, error_code& ec)
{
for (std::list<socket_entry>::iterator i = m_unicast_sockets.begin()
, end(m_unicast_sockets.end()); i != end; ++i)
{
if (!i->socket) continue;
asio::error_code e;
error_code e;
i->socket->send_to(asio::buffer(buffer, size), m_multicast_endpoint, 0, e);
#ifndef NDEBUG
// std::cerr << " sending on " << i->socket->local_endpoint().address().to_string() << " to: " << m_multicast_endpoint << std::endl;
@ -239,7 +239,7 @@ namespace libtorrent
}
}
void broadcast_socket::on_receive(socket_entry* s, asio::error_code const& ec
void broadcast_socket::on_receive(socket_entry* s, error_code const& ec
, std::size_t bytes_transferred)
{
if (ec || bytes_transferred == 0 || !m_on_receive) return;

View File

@ -1707,7 +1707,7 @@ namespace libtorrent
// --------------------------
// throws exception when the client should be disconnected
void bt_peer_connection::on_receive(asio::error_code const& error
void bt_peer_connection::on_receive(error_code const& error
, std::size_t bytes_transferred)
{
INVARIANT_CHECK;
@ -2587,7 +2587,7 @@ namespace libtorrent
// --------------------------
// throws exception when the client should be disconnected
void bt_peer_connection::on_sent(asio::error_code const& error
void bt_peer_connection::on_sent(error_code const& error
, std::size_t bytes_transferred)
{
INVARIANT_CHECK;

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/connection_queue.hpp"
#include "libtorrent/socket.hpp"
namespace libtorrent
{
@ -112,7 +113,7 @@ namespace libtorrent
void connection_queue::close()
{
asio::error_code ec;
error_code ec;
m_timer.cancel(ec);
}
@ -153,7 +154,7 @@ namespace libtorrent
if (m_queue.empty())
{
asio::error_code ec;
error_code ec;
m_timer.cancel(ec);
return;
}
@ -166,7 +167,7 @@ namespace libtorrent
ptime expire = time_now() + i->timeout;
if (m_num_connecting == 0)
{
asio::error_code ec;
error_code ec;
m_timer.expires_at(expire, ec);
m_timer.async_wait(boost::bind(&connection_queue::on_timeout, this, _1));
}
@ -206,7 +207,7 @@ namespace libtorrent
};
#endif
void connection_queue::on_timeout(asio::error_code const& e)
void connection_queue::on_timeout(error_code const& e)
{
mutex_t::scoped_lock l(m_mutex);
@ -251,7 +252,7 @@ namespace libtorrent
if (next_expire < max_time())
{
asio::error_code ec;
error_code ec;
m_timer.expires_at(next_expire, ec);
m_timer.async_wait(boost::bind(&connection_queue::on_timeout, this, _1));
}

View File

@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include "libtorrent/enum_net.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include <asio/ip/host_name.hpp>
#include <boost/asio/ip/host_name.hpp>
#if defined TORRENT_BSD
@ -225,7 +225,7 @@ namespace libtorrent
== (iface.interface_address.to_v4().to_ulong() & iface.netmask.to_v4().to_ulong());
}
bool in_local_network(asio::io_service& ios, address const& addr, asio::error_code& ec)
bool in_local_network(io_service& ios, address const& addr, error_code& ec)
{
std::vector<ip_interface> const& net = enum_net_interfaces(ios, ec);
if (ec) return false;
@ -237,7 +237,7 @@ namespace libtorrent
return false;
}
std::vector<ip_interface> enum_net_interfaces(asio::io_service& ios, asio::error_code& ec)
std::vector<ip_interface> enum_net_interfaces(io_service& ios, error_code& ec)
{
std::vector<ip_interface> ret;
// covers linux, MacOS X and BSD distributions
@ -254,7 +254,7 @@ namespace libtorrent
ifc.ifc_buf = buf;
if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
close(s);
return ret;
}
@ -283,7 +283,7 @@ namespace libtorrent
}
else
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
close(s);
return ret;
}
@ -310,7 +310,7 @@ namespace libtorrent
SOCKET s = socket(AF_INET, SOCK_DGRAM, 0);
if (s == SOCKET_ERROR)
{
ec = asio::error_code(WSAGetLastError(), asio::error::system_category);
ec = error_code(WSAGetLastError(), asio::error::system_category);
return ret;
}
@ -320,7 +320,7 @@ namespace libtorrent
if (WSAIoctl(s, SIO_GET_INTERFACE_LIST, 0, 0, buffer,
sizeof(buffer), &size, 0, 0) != 0)
{
ec = asio::error_code(WSAGetLastError(), asio::error::system_category);
ec = error_code(WSAGetLastError(), asio::error::system_category);
closesocket(s);
return ret;
}
@ -356,7 +356,7 @@ namespace libtorrent
return ret;
}
address get_default_gateway(asio::io_service& ios, asio::error_code& ec)
address get_default_gateway(io_service& ios, error_code& ec)
{
std::vector<ip_route> ret = enum_routes(ios, ec);
std::vector<ip_route>::iterator i = std::find_if(ret.begin(), ret.end()
@ -365,7 +365,7 @@ namespace libtorrent
return i->gateway;
}
std::vector<ip_route> enum_routes(asio::io_service& ios, asio::error_code& ec)
std::vector<ip_route> enum_routes(io_service& ios, error_code& ec)
{
std::vector<ip_route> ret;
@ -390,14 +390,14 @@ namespace libtorrent
int s = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);
if (s == -1)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
return std::vector<ip_route>();
}
int n = write(s, &m, len);
if (n == -1)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
close(s);
return std::vector<ip_route>();
}
@ -412,7 +412,7 @@ namespace libtorrent
n = read(s, &m, len);
if (n == -1)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
close(s);
return std::vector<ip_route>();
}
@ -423,7 +423,7 @@ namespace libtorrent
std::cout << " rtm_type: " << ptr->rtm_type << std::endl;
if (ptr->rtm_errno)
{
ec = asio::error_code(ptr->rtm_errno, asio::error::system_category);
ec = error_code(ptr->rtm_errno, asio::error::system_category);
return std::vector<ip_route>();
}
if (m.m_rtm.rtm_flags & RTF_UP == 0
@ -475,7 +475,7 @@ namespace libtorrent
size_t needed = 0;
if (sysctl(mib, 6, 0, &needed, 0, 0) < 0)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
return std::vector<ip_route>();
}
@ -493,7 +493,7 @@ namespace libtorrent
if (sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
return std::vector<ip_route>();
}
@ -562,7 +562,7 @@ namespace libtorrent
if (ec)
{
ec = asio::error_code();
ec = error_code();
continue;
}
ret.push_back(r);
@ -582,7 +582,7 @@ namespace libtorrent
int sock = socket(PF_ROUTE, SOCK_DGRAM, NETLINK_ROUTE);
if (sock < 0)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
return std::vector<ip_route>();
}
@ -600,7 +600,7 @@ namespace libtorrent
if (send(sock, nl_msg, nl_msg->nlmsg_len, 0) < 0)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
close(sock);
return std::vector<ip_route>();
}
@ -608,7 +608,7 @@ namespace libtorrent
int len = read_nl_sock(sock, msg, BUFSIZE, seq, getpid());
if (len < 0)
{
ec = asio::error_code(errno, asio::error::system_category);
ec = error_code(errno, asio::error::system_category);
close(sock);
return std::vector<ip_route>();
}

View File

@ -35,10 +35,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/instantiate_connection.hpp"
#include "libtorrent/gzip.hpp"
#include "libtorrent/tracker_manager.hpp"
#include "libtorrent/socket.hpp"
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <asio/ip/tcp.hpp>
#include <string>
using boost::bind;
@ -118,7 +118,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
if (ps) m_proxy = *ps;
m_timeout = timeout;
asio::error_code ec;
error_code ec;
m_timer.expires_from_now(m_timeout, ec);
m_timer.async_wait(bind(&http_connection::on_timeout
, boost::weak_ptr<http_connection>(shared_from_this()), _1));
@ -137,14 +137,14 @@ void http_connection::start(std::string const& hostname, std::string const& port
if (m_sock.is_open() && m_hostname == hostname && m_port == port
&& m_ssl == ssl && m_bind_addr == bind_addr)
{
asio::async_write(m_sock, asio::buffer(sendbuffer)
async_write(m_sock, asio::buffer(sendbuffer)
, bind(&http_connection::on_write, shared_from_this(), _1));
}
else
{
m_ssl = ssl;
m_bind_addr = bind_addr;
asio::error_code ec;
error_code ec;
m_sock.close(ec);
#ifdef TORRENT_USE_OPENSSL
@ -168,7 +168,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
#endif
if (m_bind_addr != address_v4::any())
{
asio::error_code ec;
error_code ec;
m_sock.bind(tcp::endpoint(m_bind_addr, 0), ec);
if (ec)
{
@ -195,7 +195,7 @@ void http_connection::on_connect_timeout()
}
void http_connection::on_timeout(boost::weak_ptr<http_connection> p
, asio::error_code const& e)
, error_code const& e)
{
boost::shared_ptr<http_connection> c = p.lock();
if (!c) return;
@ -212,14 +212,14 @@ void http_connection::on_timeout(boost::weak_ptr<http_connection> p
}
if (!c->m_sock.is_open()) return;
asio::error_code ec;
error_code ec;
c->m_timer.expires_at(c->m_last_receive + c->m_timeout, ec);
c->m_timer.async_wait(bind(&http_connection::on_timeout, p, _1));
}
void http_connection::close()
{
asio::error_code ec;
error_code ec;
m_timer.cancel(ec);
m_limiter_timer.cancel(ec);
m_sock.close(ec);
@ -232,7 +232,7 @@ void http_connection::close()
m_handler.clear();
}
void http_connection::on_resolve(asio::error_code const& e
void http_connection::on_resolve(error_code const& e
, tcp::resolver::iterator i)
{
if (e)
@ -269,14 +269,14 @@ void http_connection::connect(int ticket, tcp::endpoint target_address)
, shared_from_this(), _1/*, ++i*/));
}
void http_connection::on_connect(asio::error_code const& e
void http_connection::on_connect(error_code const& e
/*, tcp::resolver::iterator i*/)
{
if (!e)
{
m_last_receive = time_now();
if (m_connect_handler) m_connect_handler(*this);
asio::async_write(m_sock, asio::buffer(sendbuffer)
async_write(m_sock, asio::buffer(sendbuffer)
, bind(&http_connection::on_write, shared_from_this(), _1));
}
/* else if (i != tcp::resolver::iterator())
@ -294,7 +294,7 @@ void http_connection::on_connect(asio::error_code const& e
}
}
void http_connection::callback(asio::error_code const& e, char const* data, int size)
void http_connection::callback(error_code const& e, char const* data, int size)
{
if (!m_bottled || !m_called)
{
@ -321,7 +321,7 @@ void http_connection::callback(asio::error_code const& e, char const* data, int
}
}
void http_connection::on_write(asio::error_code const& e)
void http_connection::on_write(error_code const& e)
{
if (e)
{
@ -340,7 +340,7 @@ void http_connection::on_write(asio::error_code const& e)
if (m_download_quota == 0)
{
if (!m_limiter_timer_active)
on_assign_bandwidth(asio::error_code());
on_assign_bandwidth(error_code());
return;
}
}
@ -350,7 +350,7 @@ void http_connection::on_write(asio::error_code const& e)
, shared_from_this(), _1, _2));
}
void http_connection::on_read(asio::error_code const& e
void http_connection::on_read(error_code const& e
, std::size_t bytes_transferred)
{
if (m_rate_limit)
@ -394,7 +394,7 @@ void http_connection::on_read(asio::error_code const& e
if (error)
{
// HTTP parse error
asio::error_code ec = asio::error::fault;
error_code ec = asio::error::fault;
callback(ec, 0, 0);
return;
}
@ -415,7 +415,7 @@ void http_connection::on_read(asio::error_code const& e
return;
}
asio::error_code ec;
error_code ec;
m_sock.close(ec);
get(url, m_timeout, m_priority, &m_proxy, m_redirects - 1);
return;
@ -434,7 +434,7 @@ void http_connection::on_read(asio::error_code const& e
}
else if (m_bottled && m_parser.finished())
{
asio::error_code ec;
error_code ec;
m_timer.cancel(ec);
callback(e, m_parser.get_body().begin, m_parser.get_body().left());
}
@ -462,7 +462,7 @@ void http_connection::on_read(asio::error_code const& e
if (m_download_quota == 0)
{
if (!m_limiter_timer_active)
on_assign_bandwidth(asio::error_code());
on_assign_bandwidth(error_code());
return;
}
}
@ -472,7 +472,7 @@ void http_connection::on_read(asio::error_code const& e
, shared_from_this(), _1, _2));
}
void http_connection::on_assign_bandwidth(asio::error_code const& e)
void http_connection::on_assign_bandwidth(error_code const& e)
{
if ((e == asio::error::operation_aborted
&& m_limiter_timer_active)
@ -499,7 +499,7 @@ void http_connection::on_assign_bandwidth(asio::error_code const& e)
, bind(&http_connection::on_read
, shared_from_this(), _1, _2));
asio::error_code ec;
error_code ec;
m_limiter_timer_active = true;
m_limiter_timer.expires_from_now(milliseconds(250), ec);
m_limiter_timer.async_wait(bind(&http_connection::on_assign_bandwidth
@ -512,7 +512,7 @@ void http_connection::rate_limit(int limit)
if (!m_limiter_timer_active)
{
asio::error_code ec;
error_code ec;
m_limiter_timer_active = true;
m_limiter_timer.expires_from_now(milliseconds(250), ec);
m_limiter_timer.async_wait(bind(&http_connection::on_assign_bandwidth

View File

@ -38,13 +38,13 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
void http_stream::name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void http_stream::name_lookup(error_code const& e, tcp::resolver::iterator i
, boost::shared_ptr<handler_type> h)
{
if (e || i == tcp::resolver::iterator())
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -53,12 +53,12 @@ namespace libtorrent
&http_stream::connected, this, _1, h));
}
void http_stream::connected(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void http_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -82,32 +82,32 @@ namespace libtorrent
m_user + ":" + m_password) + "\r\n", p);
}
write_string("\r\n", p);
asio::async_write(m_sock, asio::buffer(m_buffer)
async_write(m_sock, asio::buffer(m_buffer)
, boost::bind(&http_stream::handshake1, this, _1, h));
}
void http_stream::handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void http_stream::handshake1(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
// read one byte from the socket
m_buffer.resize(1);
asio::async_read(m_sock, asio::buffer(m_buffer)
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&http_stream::handshake2, this, _1, h));
}
void http_stream::handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void http_stream::handshake2(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -138,7 +138,7 @@ namespace libtorrent
if (status == 0)
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -148,7 +148,7 @@ namespace libtorrent
if (code != 200)
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -160,7 +160,7 @@ namespace libtorrent
// read another byte from the socket
m_buffer.resize(read_pos + 1);
asio::async_read(m_sock, asio::buffer(&m_buffer[0] + read_pos, 1)
async_read(m_sock, asio::buffer(&m_buffer[0] + read_pos, 1)
, boost::bind(&http_stream::handshake2, this, _1, h));
}

View File

@ -194,7 +194,7 @@ namespace libtorrent
tracker_connection::close();
}
void http_tracker_connection::on_response(asio::error_code const& ec
void http_tracker_connection::on_response(error_code const& ec
, http_parser const& parser, char const* data, int size)
{
// keep this alive

View File

@ -37,12 +37,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_type.hpp"
#include <boost/shared_ptr.hpp>
#include <stdexcept>
#include <asio/io_service.hpp>
namespace libtorrent
{
bool instantiate_connection(asio::io_service& ios
bool instantiate_connection(io_service& ios
, proxy_settings const& ps, socket_type& s)
{
if (ps.type == proxy_settings::none)

View File

@ -40,8 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
using asio::ip::udp;
closest_nodes_observer::~closest_nodes_observer()
{
if (m_algorithm) m_algorithm->failed(m_self, true);

View File

@ -66,9 +66,6 @@ enum
key_refresh = 5 // generate a new write token key every 5 minutes
};
using asio::ip::udp;
typedef asio::ip::address_v4 address;
namespace
{
const int tick_period = 1; // minutes
@ -228,7 +225,7 @@ namespace libtorrent { namespace dht
s.dht_global_nodes = m_dht.num_global_nodes();
}
void dht_tracker::connection_timeout(asio::error_code const& e)
void dht_tracker::connection_timeout(error_code const& e)
try
{
mutex_t::scoped_lock l(m_mutex);
@ -247,7 +244,7 @@ namespace libtorrent { namespace dht
#endif
};
void dht_tracker::refresh_timeout(asio::error_code const& e)
void dht_tracker::refresh_timeout(error_code const& e)
try
{
mutex_t::scoped_lock l(m_mutex);
@ -263,7 +260,7 @@ namespace libtorrent { namespace dht
TORRENT_ASSERT(false);
};
void dht_tracker::tick(asio::error_code const& e)
void dht_tracker::tick(error_code const& e)
try
{
mutex_t::scoped_lock l(m_mutex);
@ -739,7 +736,7 @@ namespace libtorrent { namespace dht
bind(&dht_tracker::on_name_lookup, self(), _1, _2));
}
void dht_tracker::on_name_lookup(asio::error_code const& e
void dht_tracker::on_name_lookup(error_code const& e
, udp::resolver::iterator host) try
{
if (e || host == udp::resolver::iterator()) return;
@ -757,7 +754,7 @@ namespace libtorrent { namespace dht
bind(&dht_tracker::on_router_name_lookup, self(), _1, _2));
}
void dht_tracker::on_router_name_lookup(asio::error_code const& e
void dht_tracker::on_router_name_lookup(error_code const& e
, udp::resolver::iterator host) try
{
if (e || host == udp::resolver::iterator()) return;
@ -957,7 +954,7 @@ namespace libtorrent { namespace dht
m_send_buf.clear();
bencode(std::back_inserter(m_send_buf), e);
asio::error_code ec;
error_code ec;
m_sock.send(m.addr, &m_send_buf[0], (int)m_send_buf.size(), ec);
#ifdef TORRENT_DHT_VERBOSE_LOGGING

View File

@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/kademlia/routing_table.hpp>
#include <libtorrent/kademlia/rpc_manager.hpp>
#include <libtorrent/io.hpp>
#include <libtorrent/socket.hpp>
namespace libtorrent { namespace dht
{
@ -101,7 +102,7 @@ find_data::find_data(
add_requests();
}
void find_data::invoke(node_id const& id, asio::ip::udp::endpoint addr)
void find_data::invoke(node_id const& id, udp::endpoint addr)
{
if (m_done)
{

View File

@ -65,8 +65,6 @@ namespace
// TODO: configurable?
enum { announce_interval = 30 };
using asio::ip::udp;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_DEFINE_LOG(node)
#endif

View File

@ -47,8 +47,6 @@ using boost::bind;
namespace libtorrent { namespace dht
{
using asio::ip::udp;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_DEFINE_LOG(refresh)
#endif

View File

@ -50,9 +50,6 @@ using boost::uint8_t;
namespace libtorrent { namespace dht
{
using asio::ip::udp;
typedef asio::ip::address_v4 address;
routing_table::routing_table(node_id const& id, int bucket_size
, dht_settings const& settings)
: m_bucket_size(bucket_size)

View File

@ -39,7 +39,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
using boost::bind;
using asio::ip::udp;
namespace libtorrent { namespace dht
{

View File

@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <asio/ip/host_name.hpp>
#include <asio/ip/multicast.hpp>
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/ip/multicast.hpp>
#include <boost/thread/mutex.hpp>
#include <cstdlib>
#include <boost/config.hpp>
@ -52,7 +52,7 @@ using namespace libtorrent;
namespace libtorrent
{
// defined in broadcast_socket.cpp
address guess_local_address(asio::io_service&);
address guess_local_address(io_service&);
}
lsd::lsd(io_service& ios, address const& listen_interface
@ -84,7 +84,7 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
std::string const& msg = btsearch.str();
m_retry_count = 1;
asio::error_code ec;
error_code ec;
m_socket.send(msg.c_str(), int(msg.size()), ec);
if (ec)
{
@ -101,11 +101,11 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
m_broadcast_timer.async_wait(bind(&lsd::resend_announce, self(), _1, msg));
}
void lsd::resend_announce(asio::error_code const& e, std::string msg)
void lsd::resend_announce(error_code const& e, std::string msg)
{
if (e) return;
asio::error_code ec;
error_code ec;
m_socket.send(msg.c_str(), int(msg.size()), ec);
++m_retry_count;
@ -192,7 +192,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
void lsd::close()
{
m_socket.close();
asio::error_code ec;
error_code ec;
m_broadcast_timer.cancel(ec);
m_disabled = true;
m_callback.clear();

View File

@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/pch.hpp"
#include <boost/bind.hpp>
#include <asio/ip/host_name.hpp>
#include <boost/asio/ip/host_name.hpp>
#include "libtorrent/natpmp.hpp"
#include "libtorrent/io.hpp"
@ -63,7 +63,7 @@ void natpmp::rebind(address const& listen_interface)
{
mutex_t::scoped_lock l(m_mutex);
asio::error_code ec;
error_code ec;
address gateway = get_default_gateway(m_socket.get_io_service(), ec);
if (ec)
{
@ -198,7 +198,7 @@ void natpmp::try_next_mapping(int i)
{
if (m_abort)
{
asio::error_code ec;
error_code ec;
m_send_timer.cancel(ec);
m_socket.close(ec);
}
@ -264,7 +264,7 @@ void natpmp::send_map_request(int i)
<< " ttl: " << ttl << " ]" << std::endl;
#endif
asio::error_code ec;
error_code ec;
m_socket.send_to(asio::buffer(buf, 12), m_nat_endpoint, 0, ec);
// linear back-off instead of exponential
++m_retry_count;
@ -272,7 +272,7 @@ void natpmp::send_map_request(int i)
m_send_timer.async_wait(bind(&natpmp::resend_request, self(), i, _1));
}
void natpmp::resend_request(int i, asio::error_code const& e)
void natpmp::resend_request(int i, error_code const& e)
{
if (e) return;
@ -290,7 +290,7 @@ void natpmp::resend_request(int i, asio::error_code const& e)
send_map_request(i);
}
void natpmp::on_reply(asio::error_code const& e
void natpmp::on_reply(error_code const& e
, std::size_t bytes_transferred)
{
using namespace libtorrent::detail;
@ -305,7 +305,7 @@ void natpmp::on_reply(asio::error_code const& e
mutex_t::scoped_lock l(m_mutex);
asio::error_code ec;
error_code ec;
m_send_timer.cancel(ec);
TORRENT_ASSERT(m_currently_mapping >= 0);
@ -439,7 +439,7 @@ void natpmp::update_expiration_timer()
<< " ttl: " << total_seconds(min_expire - time_now())
<< " ]" << std::endl;
#endif
asio::error_code ec;
error_code ec;
if (m_next_refresh >= 0) m_refresh_timer.cancel(ec);
m_refresh_timer.expires_from_now(min_expire - now, ec);
m_refresh_timer.async_wait(bind(&natpmp::mapping_expired, self(), _1, min_index));
@ -447,7 +447,7 @@ void natpmp::update_expiration_timer()
}
}
void natpmp::mapping_expired(asio::error_code const& e, int i)
void natpmp::mapping_expired(error_code const& e, int i)
{
if (e) return;
mutex_t::scoped_lock l(m_mutex);
@ -463,7 +463,7 @@ void natpmp::close()
{
mutex_t::scoped_lock l(m_mutex);
m_abort = true;
asio::error_code ec;
error_code ec;
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << time_now_string() << " close" << std::endl;
#endif

View File

@ -243,7 +243,7 @@ namespace libtorrent
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
asio::error_code ec;
error_code ec;
TORRENT_ASSERT(m_socket->remote_endpoint() == remote() || ec);
m_logger = m_ses.create_log(remote().address().to_string(ec) + "_"
+ boost::lexical_cast<std::string>(remote().port()), m_ses.listen_port());
@ -291,7 +291,7 @@ namespace libtorrent
if (!t)
{
tcp::socket::non_blocking_io ioc(true);
asio::error_code ec;
error_code ec;
m_socket->io_control(ioc, ec);
if (ec)
{
@ -2207,7 +2207,7 @@ namespace libtorrent
#endif
m_disconnecting = true;
asio::error_code ec;
error_code ec;
m_socket->close(ec);
m_ses.close_connection(this, message);
}
@ -2998,7 +2998,7 @@ namespace libtorrent
// --------------------------
// throws exception when the client should be disconnected
void peer_connection::on_receive_data(const asio::error_code& error
void peer_connection::on_receive_data(const error_code& error
, std::size_t bytes_transferred)
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
@ -3063,7 +3063,7 @@ namespace libtorrent
if (int(m_recv_buffer.size()) < regular_buffer_size)
m_recv_buffer.resize(regular_buffer_size);
asio::error_code ec;
error_code ec;
if (m_disk_recv_buffer == 0 || regular_buffer_size >= m_recv_pos + max_receive)
{
// only receive into regular buffer
@ -3158,7 +3158,7 @@ namespace libtorrent
{
INVARIANT_CHECK;
asio::error_code ec;
error_code ec;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << time_now_string() << " CONNECTING: " << m_remote.address().to_string(ec)
<< ":" << m_remote.port() << "\n";
@ -3209,7 +3209,7 @@ namespace libtorrent
}
}
void peer_connection::on_connection_complete(asio::error_code const& e)
void peer_connection::on_connection_complete(error_code const& e)
{
ptime completed = time_now();
@ -3247,7 +3247,7 @@ namespace libtorrent
if (m_remote.address().is_v4())
{
asio::error_code ec;
error_code ec;
m_socket->set_option(type_of_service(m_ses.settings().peer_tos), ec);
}
@ -3261,7 +3261,7 @@ namespace libtorrent
// --------------------------
// throws exception when the client should be disconnected
void peer_connection::on_send_data(asio::error_code const& error
void peer_connection::on_send_data(error_code const& error
, std::size_t bytes_transferred)
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);

View File

@ -225,7 +225,7 @@ namespace libtorrent
// blocks be from whole pieces, possibly by returning more blocks
// than we requested.
#ifndef NDEBUG
asio::error_code ec;
error_code ec;
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec);
#endif
@ -625,7 +625,7 @@ namespace libtorrent
// TODO: only allow _one_ connection to use this
// override at a time
asio::error_code ec;
error_code ec;
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec);
aux::session_impl& ses = m_torrent->session();
@ -697,7 +697,7 @@ namespace libtorrent
{
// we don't have any info about this peer.
// add a new entry
asio::error_code ec;
error_code ec;
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec);
peer p(c.remote(), peer::not_connectable, 0);
@ -1156,7 +1156,7 @@ namespace libtorrent
// INVARIANT_CHECK;
TORRENT_ASSERT(c);
asio::error_code ec;
error_code ec;
TORRENT_ASSERT(c->remote() == c->get_socket()->remote_endpoint(ec) || ec);
return std::find_if(

View File

@ -250,7 +250,7 @@ namespace aux {
*i = printable[rand() % (sizeof(printable)-1)];
}
asio::error_code ec;
error_code ec;
m_timer.expires_from_now(seconds(1), ec);
m_timer.async_wait(
bind(&session_impl::second_tick, this, _1));
@ -396,7 +396,7 @@ namespace aux {
if (m_dht) m_dht->stop();
m_dht_socket.close();
#endif
asio::error_code ec;
error_code ec;
m_timer.cancel(ec);
// close the listen sockets
@ -535,7 +535,7 @@ namespace aux {
session_impl::listen_socket_t session_impl::setup_listener(tcp::endpoint ep
, int retries, bool v6_only)
{
asio::error_code ec;
error_code ec;
listen_socket_t s;
s.sock.reset(new socket_acceptor(m_io_service));
s.sock->open(ep.protocol(), ec);
@ -544,7 +544,7 @@ namespace aux {
s.sock->bind(ep, ec);
while (ec && retries > 0)
{
ec = asio::error_code();
ec = error_code();
TORRENT_ASSERT(!ec);
--retries;
ep.port(ep.port() + 1);
@ -555,7 +555,7 @@ namespace aux {
// instead of giving up, try
// let the OS pick a port
ep.port(0);
ec = asio::error_code();
ec = error_code();
s.sock->bind(ep, ec);
}
if (ec)
@ -661,7 +661,7 @@ namespace aux {
for (std::list<listen_socket_t>::const_iterator i = m_listen_sockets.begin()
, end(m_listen_sockets.end()); i != end; ++i)
{
asio::error_code ec;
error_code ec;
tcp::endpoint ep = i->sock->local_endpoint(ec);
if (ec || ep.address().is_v4()) continue;
@ -691,7 +691,7 @@ namespace aux {
if (!m_listen_sockets.empty())
{
asio::error_code ec;
error_code ec;
tcp::endpoint local = m_listen_sockets.front().sock->local_endpoint(ec);
if (!ec)
{
@ -713,7 +713,7 @@ namespace aux {
#ifndef TORRENT_DISABLE_DHT
void session_impl::on_receive_udp(asio::error_code const& e
void session_impl::on_receive_udp(error_code const& e
, udp::endpoint const& ep, char const* buf, int len)
{
if (e)
@ -746,7 +746,7 @@ namespace aux {
}
void session_impl::on_incoming_connection(shared_ptr<socket_type> const& s
, weak_ptr<socket_acceptor> listen_socket, asio::error_code const& e)
, weak_ptr<socket_acceptor> listen_socket, error_code const& e)
{
boost::shared_ptr<socket_acceptor> listener = listen_socket.lock();
if (!listener) return;
@ -756,7 +756,7 @@ namespace aux {
mutex_t::scoped_lock l(m_mutex);
if (m_abort) return;
asio::error_code ec;
error_code ec;
if (e)
{
tcp::endpoint ep = listener->local_endpoint(ec);
@ -926,7 +926,7 @@ namespace aux {
return port;
}
void session_impl::second_tick(asio::error_code const& e)
void session_impl::second_tick(error_code const& e)
{
session_impl::mutex_t::scoped_lock l(m_mutex);
@ -947,7 +947,7 @@ namespace aux {
float tick_interval = total_microseconds(time_now() - m_last_tick) / 1000000.f;
m_last_tick = time_now();
asio::error_code ec;
error_code ec;
m_timer.expires_from_now(seconds(1), ec);
m_timer.async_wait(
bind(&session_impl::second_tick, this, _1));

View File

@ -37,13 +37,13 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
void socks4_stream::name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void socks4_stream::name_lookup(error_code const& e, tcp::resolver::iterator i
, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -54,7 +54,7 @@ namespace libtorrent
if (i == tcp::resolver::iterator())
{
asio::error_code ec = asio::error::operation_not_supported;
error_code ec = asio::error::operation_not_supported;
(*h)(ec);
close(ec);
return;
@ -64,12 +64,12 @@ namespace libtorrent
&socks4_stream::connected, this, _1, h));
}
void socks4_stream::connected(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks4_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -86,31 +86,31 @@ namespace libtorrent
p += m_user.size();
write_uint8(0, p); // NULL terminator
asio::async_write(m_sock, asio::buffer(m_buffer)
async_write(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks4_stream::handshake1, this, _1, h));
}
void socks4_stream::handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks4_stream::handshake1(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
m_buffer.resize(8);
asio::async_read(m_sock, asio::buffer(m_buffer)
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks4_stream::handshake2, this, _1, h));
}
void socks4_stream::handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks4_stream::handshake2(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -123,7 +123,7 @@ namespace libtorrent
if (reply_version != 0)
{
asio::error_code ec = asio::error::operation_not_supported;
error_code ec = asio::error::operation_not_supported;
(*h)(ec);
close(ec);
return;
@ -137,7 +137,7 @@ namespace libtorrent
return;
}
asio::error_code ec = asio::error::fault;
error_code ec = asio::error::fault;
switch (status_code)
{
case 91: ec = asio::error::connection_refused; break;

View File

@ -38,13 +38,13 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
void socks5_stream::name_lookup(asio::error_code const& e, tcp::resolver::iterator i
void socks5_stream::name_lookup(error_code const& e, tcp::resolver::iterator i
, boost::shared_ptr<handler_type> h)
{
if (e || i == tcp::resolver::iterator())
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -53,12 +53,12 @@ namespace libtorrent
&socks5_stream::connected, this, _1, h));
}
void socks5_stream::connected(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks5_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -79,31 +79,31 @@ namespace libtorrent
write_uint8(0, p); // no authentication
write_uint8(2, p); // username/password
}
asio::async_write(m_sock, asio::buffer(m_buffer)
async_write(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake1, this, _1, h));
}
void socks5_stream::handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks5_stream::handshake1(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
m_buffer.resize(2);
asio::async_read(m_sock, asio::buffer(m_buffer)
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake2, this, _1, h));
}
void socks5_stream::handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks5_stream::handshake2(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -117,7 +117,7 @@ namespace libtorrent
if (version < 5)
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -131,7 +131,7 @@ namespace libtorrent
if (m_user.empty())
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -144,41 +144,41 @@ namespace libtorrent
write_string(m_user, p);
write_uint8(m_password.size(), p);
write_string(m_password, p);
asio::async_write(m_sock, asio::buffer(m_buffer)
async_write(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake3, this, _1, h));
}
else
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
}
void socks5_stream::handshake3(asio::error_code const& e
void socks5_stream::handshake3(error_code const& e
, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
m_buffer.resize(2);
asio::async_read(m_sock, asio::buffer(m_buffer)
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake4, this, _1, h));
}
void socks5_stream::handshake4(asio::error_code const& e
void socks5_stream::handshake4(error_code const& e
, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -192,7 +192,7 @@ namespace libtorrent
if (version != 1)
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -200,7 +200,7 @@ namespace libtorrent
if (status != 0)
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -223,31 +223,31 @@ namespace libtorrent
write_endpoint(m_remote_endpoint, p);
TORRENT_ASSERT(p - &m_buffer[0] == int(m_buffer.size()));
asio::async_write(m_sock, asio::buffer(m_buffer)
async_write(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::connect1, this, _1, h));
}
void socks5_stream::connect1(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks5_stream::connect1(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
m_buffer.resize(6 + 4); // assume an IPv4 address
asio::async_read(m_sock, asio::buffer(m_buffer)
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::connect2, this, _1, h));
}
void socks5_stream::connect2(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks5_stream::connect2(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -260,14 +260,14 @@ namespace libtorrent
if (version < 5)
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
int response = read_uint8(p);
if (response != 0)
{
asio::error_code e = asio::error::fault;
error_code e = asio::error::fault;
switch (response)
{
case 1: e = asio::error::fault; break;
@ -280,7 +280,7 @@ namespace libtorrent
case 8: e = asio::error::address_family_not_supported; break;
}
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
@ -305,22 +305,22 @@ namespace libtorrent
else
{
(*h)(asio::error::operation_not_supported);
asio::error_code ec;
error_code ec;
close(ec);
return;
}
m_buffer.resize(skip_bytes);
asio::async_read(m_sock, asio::buffer(m_buffer)
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::connect3, this, _1, h));
}
void socks5_stream::connect3(asio::error_code const& e, boost::shared_ptr<handler_type> h)
void socks5_stream::connect3(error_code const& e, boost::shared_ptr<handler_type> h)
{
if (e)
{
(*h)(e);
asio::error_code ec;
error_code ec;
close(ec);
return;
}

View File

@ -307,7 +307,7 @@ namespace libtorrent
boost::weak_ptr<torrent> self(shared_from_this());
if (m_torrent_file->is_valid()) init();
if (m_abort) return;
asio::error_code ec;
error_code ec;
m_announce_timer.expires_from_now(seconds(1), ec);
m_announce_timer.async_wait(
bind(&torrent::on_announce_disp, self, _1));
@ -673,7 +673,7 @@ namespace libtorrent
}
void torrent::on_announce_disp(boost::weak_ptr<torrent> p
, asio::error_code const& e)
, error_code const& e)
{
if (e) return;
boost::shared_ptr<torrent> t = p.lock();
@ -687,7 +687,7 @@ namespace libtorrent
boost::weak_ptr<torrent> self(shared_from_this());
asio::error_code ec;
error_code ec;
if (!m_torrent_file->priv())
{
// announce on local network every 5 minutes
@ -865,7 +865,7 @@ namespace libtorrent
if (i->pid == m_ses.get_peer_id())
continue;
asio::error_code ec;
error_code ec;
tcp::endpoint a(address::from_string(i->ip, ec), i->port);
if (ec)
@ -905,7 +905,7 @@ namespace libtorrent
m_got_tracker_response = true;
}
void torrent::on_peer_name_lookup(asio::error_code const& e, tcp::resolver::iterator host
void torrent::on_peer_name_lookup(error_code const& e, tcp::resolver::iterator host
, peer_id pid)
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
@ -1369,7 +1369,7 @@ namespace libtorrent
bind(&torrent::on_files_released, shared_from_this(), _1, _2));
m_owning_storage = 0;
asio::error_code ec;
error_code ec;
m_announce_timer.cancel(ec);
m_host_resolver.cancel();
}
@ -1976,7 +1976,7 @@ namespace libtorrent
}
void torrent::on_proxy_name_lookup(asio::error_code const& e, tcp::resolver::iterator host
void torrent::on_proxy_name_lookup(error_code const& e, tcp::resolver::iterator host
, std::string url)
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
@ -2028,7 +2028,7 @@ namespace libtorrent
bind(&torrent::on_name_lookup, shared_from_this(), _1, _2, url, a));
}
void torrent::on_name_lookup(asio::error_code const& e, tcp::resolver::iterator host
void torrent::on_name_lookup(error_code const& e, tcp::resolver::iterator host
, std::string url, tcp::endpoint proxy)
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
@ -2090,7 +2090,7 @@ namespace libtorrent
}
std::pair<int, int> const& out_ports = m_settings.outgoing_ports;
asio::error_code ec;
error_code ec;
if (out_ports.first > 0 && out_ports.second >= out_ports.first)
s->bind(tcp::endpoint(address(), m_ses.next_port()), ec);
@ -2176,7 +2176,7 @@ namespace libtorrent
};
}
void torrent::on_country_lookup(asio::error_code const& error, tcp::resolver::iterator i
void torrent::on_country_lookup(error_code const& error, tcp::resolver::iterator i
, intrusive_ptr<peer_connection> p) const
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
@ -2369,7 +2369,7 @@ namespace libtorrent
for (policy::const_iterator i = m_policy.begin_peer()
, end(m_policy.end_peer()); i != end; ++i)
{
asio::error_code ec;
error_code ec;
if (i->second.banned)
{
tcp::endpoint ip = i->second.ip;
@ -2538,7 +2538,7 @@ namespace libtorrent
bool ret = instantiate_connection(m_ses.m_io_service, m_ses.peer_proxy(), *s);
TORRENT_ASSERT(ret);
std::pair<int, int> const& out_ports = m_ses.settings().outgoing_ports;
asio::error_code ec;
error_code ec;
if (out_ports.first > 0 && out_ports.second >= out_ports.first)
s->bind(tcp::endpoint(address(), m_ses.next_port()), ec);
@ -2683,7 +2683,7 @@ namespace libtorrent
TORRENT_ASSERT(m_connections.find(p) == m_connections.end());
peer_iterator ci = m_connections.insert(p).first;
#ifndef NDEBUG
asio::error_code ec;
error_code ec;
TORRENT_ASSERT(p->remote() == p->get_socket()->remote_endpoint(ec) || ec);
#endif

View File

@ -84,7 +84,7 @@ namespace libtorrent
int timeout = (std::min)(
m_read_timeout, (std::min)(m_completion_timeout, m_read_timeout));
asio::error_code ec;
error_code ec;
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
m_timeout.async_wait(bind(
&timeout_handler::timeout_callback, self(), _1));
@ -99,11 +99,11 @@ namespace libtorrent
{
m_abort = true;
m_completion_timeout = 0;
asio::error_code ec;
error_code ec;
m_timeout.cancel(ec);
}
void timeout_handler::timeout_callback(asio::error_code const& error)
void timeout_handler::timeout_callback(error_code const& error)
{
if (error) return;
if (m_completion_timeout == 0) return;
@ -125,7 +125,7 @@ namespace libtorrent
int timeout = (std::min)(
m_read_timeout, (std::min)(m_completion_timeout, m_read_timeout));
asio::error_code ec;
error_code ec;
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
m_timeout.async_wait(
bind(&timeout_handler::timeout_callback, self(), _1));

View File

@ -4,7 +4,7 @@
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/array.hpp>
#include <asio/read.hpp>
#include <boost/asio/read.hpp>
using namespace libtorrent;
@ -22,7 +22,7 @@ udp_socket::udp_socket(asio::io_service& ios, udp_socket::callback_t const& c
{
}
void udp_socket::send(udp::endpoint const& ep, char const* p, int len, asio::error_code& ec)
void udp_socket::send(udp::endpoint const& ep, char const* p, int len, error_code& ec)
{
if (ec == asio::error::operation_aborted) return;
@ -39,7 +39,7 @@ void udp_socket::send(udp::endpoint const& ep, char const* p, int len, asio::err
m_ipv6_sock.send_to(asio::buffer(p, len), ep, 0, ec);
}
void udp_socket::on_read(udp::socket* s, asio::error_code const& e, std::size_t bytes_transferred)
void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_transferred)
{
if (e == asio::error::operation_aborted) return;
@ -113,7 +113,7 @@ void udp_socket::on_read(udp::socket* s, asio::error_code const& e, std::size_t
}
}
void udp_socket::wrap(udp::endpoint const& ep, char const* p, int len, asio::error_code& ec)
void udp_socket::wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec)
{
using namespace libtorrent::detail;
@ -137,7 +137,7 @@ void udp_socket::wrap(udp::endpoint const& ep, char const* p, int len, asio::err
}
// unwrap the UDP packet from the SOCKS5 header
void udp_socket::unwrap(asio::error_code const& e, char const* buf, int size)
void udp_socket::unwrap(error_code const& e, char const* buf, int size)
{
using namespace libtorrent::detail;
@ -174,7 +174,7 @@ void udp_socket::unwrap(asio::error_code const& e, char const* buf, int size)
void udp_socket::close()
{
asio::error_code ec;
error_code ec;
m_ipv4_sock.close(ec);
m_ipv6_sock.close(ec);
m_socks5_sock.close(ec);
@ -186,7 +186,7 @@ void udp_socket::close()
}
}
void udp_socket::bind(udp::endpoint const& ep, asio::error_code& ec)
void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
{
if (m_ipv4_sock.is_open()) m_ipv4_sock.close(ec);
if (m_ipv6_sock.is_open()) m_ipv6_sock.close(ec);
@ -214,7 +214,7 @@ void udp_socket::bind(udp::endpoint const& ep, asio::error_code& ec)
void udp_socket::bind(int port)
{
asio::error_code ec;
error_code ec;
if (m_ipv4_sock.is_open()) m_ipv4_sock.close(ec);
if (m_ipv6_sock.is_open()) m_ipv6_sock.close(ec);
@ -239,7 +239,7 @@ void udp_socket::bind(int port)
void udp_socket::set_proxy_settings(proxy_settings const& ps)
{
asio::error_code ec;
error_code ec;
m_socks5_sock.close(ec);
m_tunnel_packets = false;
@ -256,7 +256,7 @@ void udp_socket::set_proxy_settings(proxy_settings const& ps)
}
}
void udp_socket::on_name_lookup(asio::error_code const& e, tcp::resolver::iterator i)
void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
{
if (e) return;
m_proxy_addr.address(i->endpoint().address());
@ -267,7 +267,7 @@ void udp_socket::on_name_lookup(asio::error_code const& e, tcp::resolver::iterat
void udp_socket::on_timeout()
{
asio::error_code ec;
error_code ec;
m_socks5_sock.close(ec);
m_connection_ticket = -1;
}
@ -275,13 +275,13 @@ void udp_socket::on_timeout()
void udp_socket::on_connect(int ticket)
{
m_connection_ticket = ticket;
asio::error_code ec;
error_code ec;
m_socks5_sock.open(m_proxy_addr.address().is_v4()?tcp::v4():tcp::v6(), ec);
m_socks5_sock.async_connect(tcp::endpoint(m_proxy_addr.address(), m_proxy_addr.port())
, boost::bind(&udp_socket::on_connected, this, _1));
}
void udp_socket::on_connected(asio::error_code const& e)
void udp_socket::on_connected(error_code const& e)
{
m_cc.done(m_connection_ticket);
m_connection_ticket = -1;
@ -308,7 +308,7 @@ void udp_socket::on_connected(asio::error_code const& e)
, boost::bind(&udp_socket::handshake1, this, _1));
}
void udp_socket::handshake1(asio::error_code const& e)
void udp_socket::handshake1(error_code const& e)
{
if (e) return;
@ -316,7 +316,7 @@ void udp_socket::handshake1(asio::error_code const& e)
, boost::bind(&udp_socket::handshake2, this, _1));
}
void udp_socket::handshake2(asio::error_code const& e)
void udp_socket::handshake2(error_code const& e)
{
if (e) return;
@ -336,7 +336,7 @@ void udp_socket::handshake2(asio::error_code const& e)
{
if (m_proxy_settings.username.empty())
{
asio::error_code ec;
error_code ec;
m_socks5_sock.close(ec);
return;
}
@ -353,13 +353,13 @@ void udp_socket::handshake2(asio::error_code const& e)
}
else
{
asio::error_code ec;
error_code ec;
m_socks5_sock.close(ec);
return;
}
}
void udp_socket::handshake3(asio::error_code const& e)
void udp_socket::handshake3(error_code const& e)
{
if (e) return;
@ -367,7 +367,7 @@ void udp_socket::handshake3(asio::error_code const& e)
, boost::bind(&udp_socket::handshake4, this, _1));
}
void udp_socket::handshake4(asio::error_code const& e)
void udp_socket::handshake4(error_code const& e)
{
if (e) return;
@ -400,7 +400,7 @@ void udp_socket::socks_forward_udp()
, boost::bind(&udp_socket::connect1, this, _1));
}
void udp_socket::connect1(asio::error_code const& e)
void udp_socket::connect1(error_code const& e)
{
if (e) return;
@ -408,7 +408,7 @@ void udp_socket::connect1(asio::error_code const& e)
, boost::bind(&udp_socket::connect2, this, _1));
}
void udp_socket::connect2(asio::error_code const& e)
void udp_socket::connect2(error_code const& e)
{
if (e) return;

View File

@ -113,7 +113,7 @@ namespace libtorrent
#endif
}
void udp_tracker_connection::name_lookup(asio::error_code const& error
void udp_tracker_connection::name_lookup(error_code const& error
, udp::resolver::iterator i)
{
if (error == asio::error::operation_aborted) return;
@ -156,7 +156,7 @@ namespace libtorrent
if (cb) cb->m_tracker_address = tcp::endpoint(target_address.address(), target_address.port());
m_target = target_address;
asio::error_code ec;
error_code ec;
m_socket.bind(udp::endpoint(bind_interface(), 0), ec);
if (ec)
{
@ -179,13 +179,13 @@ namespace libtorrent
void udp_tracker_connection::close()
{
asio::error_code ec;
error_code ec;
m_socket.close();
m_name_lookup.cancel();
tracker_connection::close();
}
void udp_tracker_connection::on_receive(asio::error_code const& e
void udp_tracker_connection::on_receive(error_code const& e
, udp::endpoint const& ep, char const* buf, int size)
{
// ignore resposes before we've sent any requests
@ -305,7 +305,7 @@ namespace libtorrent
detail::write_int32(m_transaction_id, ptr); // transaction_id
TORRENT_ASSERT(ptr - buf == sizeof(buf));
asio::error_code ec;
error_code ec;
m_socket.send(m_target, buf, 16, ec);
m_state = action_connect;
++m_attempts;
@ -334,7 +334,7 @@ namespace libtorrent
out += 20;
TORRENT_ASSERT(out - buf == sizeof(buf));
asio::error_code ec;
error_code ec;
m_socket.send(m_target, buf, sizeof(buf), ec);
m_state = action_scrape;
++m_attempts;
@ -494,7 +494,7 @@ namespace libtorrent
}
#endif
asio::error_code ec;
error_code ec;
m_socket.send(m_target, buf, sizeof(buf), ec);
m_state = action_announce;
++m_attempts;

View File

@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <asio/ip/host_name.hpp>
#include <asio/ip/multicast.hpp>
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/ip/multicast.hpp>
#include <boost/thread/mutex.hpp>
#include <cstdlib>
@ -57,7 +57,7 @@ using namespace libtorrent;
namespace libtorrent
{
bool is_local(address const& a);
address guess_local_address(asio::io_service&);
address guess_local_address(io_service&);
}
upnp::upnp(io_service& ios, connection_queue& cc
@ -103,7 +103,7 @@ void upnp::discover_device_impl()
"MX:3\r\n"
"\r\n\r\n";
asio::error_code ec;
error_code ec;
#ifdef TORRENT_DEBUG_UPNP
// simulate packet loss
if (m_retry_count & 1)
@ -215,7 +215,7 @@ void upnp::delete_mapping(int mapping)
}
}
void upnp::resend_request(asio::error_code const& e)
void upnp::resend_request(error_code const& e)
{
if (e) return;
@ -306,7 +306,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
Server:Microsoft-Windows-NT/5.1 UPnP/1.0 UPnP-Device-Host/1.0
*/
asio::error_code ec;
error_code ec;
if (m_ignore_outside_network && !in_local_network(m_io_service, from.address(), ec))
{
// this upnp device is filtered because it's not in the
@ -453,7 +453,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
// just to make sure we find all devices
if (m_retry_count >= 4 && !m_devices.empty())
{
asio::error_code ec;
error_code ec;
m_broadcast_timer.cancel(ec);
for (std::set<rootdevice>::iterator i = m_devices.begin()
@ -543,7 +543,7 @@ void upnp::create_port_mapping(http_connection& c, rootdevice& d, int i)
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
"<s:Body><u:" << soap_action << " xmlns:u=\"" << d.service_namespace << "\">";
asio::error_code ec;
error_code ec;
soap << "<NewRemoteHost></NewRemoteHost>"
"<NewExternalPort>" << d.mapping[i].external_port << "</NewExternalPort>"
"<NewProtocol>" << (d.mapping[i].protocol == udp ? "UDP" : "TCP") << "</NewProtocol>"
@ -732,7 +732,7 @@ namespace
}
void upnp::on_upnp_xml(asio::error_code const& e
void upnp::on_upnp_xml(error_code const& e
, libtorrent::http_parser const& p, rootdevice& d)
{
mutex_t::scoped_lock l(m_mutex);
@ -833,7 +833,7 @@ void upnp::disable(char const* msg)
}
m_devices.clear();
asio::error_code ec;
error_code ec;
m_broadcast_timer.cancel(ec);
m_refresh_timer.cancel(ec);
m_socket.close();
@ -891,7 +891,7 @@ namespace
}
void upnp::on_upnp_map_response(asio::error_code const& e
void upnp::on_upnp_map_response(error_code const& e
, libtorrent::http_parser const& p, rootdevice& d, int mapping)
{
mutex_t::scoped_lock l(m_mutex);
@ -1014,7 +1014,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e
if (next_expire < time_now()
|| next_expire > m.expires)
{
asio::error_code ec;
error_code ec;
m_refresh_timer.expires_at(m.expires, ec);
m_refresh_timer.async_wait(bind(&upnp::on_expire, self(), _1));
}
@ -1046,7 +1046,7 @@ void upnp::return_error(int mapping, int code)
m_callback(mapping, 0, error_string);
}
void upnp::on_upnp_unmap_response(asio::error_code const& e
void upnp::on_upnp_unmap_response(error_code const& e
, libtorrent::http_parser const& p, rootdevice& d, int mapping)
{
mutex_t::scoped_lock l(m_mutex);
@ -1093,7 +1093,7 @@ void upnp::on_upnp_unmap_response(asio::error_code const& e
next(d, mapping);
}
void upnp::on_expire(asio::error_code const& e)
void upnp::on_expire(error_code const& e)
{
if (e) return;
@ -1125,7 +1125,7 @@ void upnp::on_expire(asio::error_code const& e)
}
if (next_expire != max_time())
{
asio::error_code ec;
error_code ec;
m_refresh_timer.expires_at(next_expire, ec);
m_refresh_timer.async_wait(bind(&upnp::on_expire, self(), _1));
}
@ -1135,7 +1135,7 @@ void upnp::close()
{
mutex_t::scoped_lock l(m_mutex);
asio::error_code ec;
error_code ec;
m_refresh_timer.cancel(ec);
m_broadcast_timer.cancel(ec);
m_closing = true;

View File

@ -315,7 +315,7 @@ namespace libtorrent
}
}
void web_peer_connection::on_receive(asio::error_code const& error
void web_peer_connection::on_receive(error_code const& error
, std::size_t bytes_transferred)
{
INVARIANT_CHECK;
@ -662,7 +662,7 @@ namespace libtorrent
}
// throws exception when the client should be disconnected
void web_peer_connection::on_sent(asio::error_code const& error
void web_peer_connection::on_sent(error_code const& error
, std::size_t bytes_transferred)
{
INVARIANT_CHECK;

View File

@ -239,7 +239,7 @@ typedef std::vector<boost::intrusive_ptr<peer_connection> > connections_t;
bool abort_tick = false;
void do_tick(asio::error_code const&e, deadline_timer& tick, connections_t& v)
void do_tick(error_code const&e, deadline_timer& tick, connections_t& v)
{
if (e || abort_tick)
{
@ -261,7 +261,7 @@ void do_stop(deadline_timer& tick, connections_t& v)
std::cerr << " stopping..." << std::endl;
}
void do_change_rate(asio::error_code const&e, deadline_timer& tick
void do_change_rate(error_code const&e, deadline_timer& tick
, boost::shared_ptr<torrent> t1
, boost::shared_ptr<torrent> t2
, int limit
@ -284,7 +284,7 @@ void do_change_rate(asio::error_code const&e, deadline_timer& tick
tick.async_wait(boost::bind(&do_change_rate, _1, boost::ref(tick), t1, t2, limit, counter-1));
}
void do_change_peer_rate(asio::error_code const&e, deadline_timer& tick
void do_change_peer_rate(error_code const&e, deadline_timer& tick
, connections_t& v
, int limit
, int counter)

View File

@ -44,6 +44,8 @@ POSSIBILITY OF SUCH DAMAGE.
using libtorrent::buffer;
using libtorrent::chained_buffer;
namespace asio = boost::asio;
/*
template<class T>
T const& min_(T const& x, T const& y)

View File

@ -3,8 +3,6 @@
#include "libtorrent/socket.hpp"
#include "libtorrent/io.hpp"
#include <cstring>
#include <asio/read.hpp>
#include <asio/write.hpp>
#include <boost/bind.hpp>
using namespace libtorrent;
@ -12,7 +10,7 @@ using namespace libtorrent;
int read_message(stream_socket& s, char* buffer)
{
using namespace libtorrent::detail;
asio::error_code ec;
error_code ec;
asio::read(s, asio::buffer(buffer, 4), asio::transfer_all(), ec);
if (ec)
{
@ -42,7 +40,7 @@ void send_allow_fast(stream_socket& s, int piece)
char msg[] = "\0\0\0\x05\x11\0\0\0\0";
char* ptr = msg + 5;
write_int32(piece, ptr);
asio::error_code ec;
error_code ec;
asio::write(s, asio::buffer(msg, 9), asio::transfer_all(), ec);
if (ec)
{
@ -58,7 +56,7 @@ void send_suggest_piece(stream_socket& s, int piece)
char msg[] = "\0\0\0\x05\x0d\0\0\0\0";
char* ptr = msg + 5;
write_int32(piece, ptr);
asio::error_code ec;
error_code ec;
asio::write(s, asio::buffer(msg, 9), asio::transfer_all(), ec);
if (ec)
{
@ -71,7 +69,7 @@ void send_unchoke(stream_socket& s)
{
std::cout << "send unchoke" << std::endl;
char msg[] = "\0\0\0\x01\x01";
asio::error_code ec;
error_code ec;
asio::write(s, asio::buffer(msg, 5), asio::transfer_all(), ec);
if (ec)
{
@ -87,7 +85,7 @@ void do_handshake(stream_socket& s, sha1_hash const& ih, char* buffer)
"aaaaaaaaaaaaaaaaaaaa" // peer-id
"\0\0\0\x01\x0e"; // have_all
std::cout << "send handshake" << std::endl;
asio::error_code ec;
error_code ec;
std::memcpy(handshake + 28, ih.begin(), 20);
asio::write(s, asio::buffer(handshake, sizeof(handshake) - 1), asio::transfer_all(), ec);
if (ec)
@ -173,7 +171,7 @@ void test_reject_fast()
allowed_fast.erase(i);
// send reject request
recv_buffer[0] = 0x10;
asio::error_code ec;
error_code ec;
asio::write(s, asio::buffer("\0\0\0\x0d", 4), asio::transfer_all(), ec);
if (ec)
{
@ -241,7 +239,7 @@ void test_respect_suggest()
suggested.erase(i);
// send reject request
recv_buffer[0] = 0x10;
asio::error_code ec;
error_code ec;
asio::write(s, asio::buffer("\0\0\0\x0d", 4), asio::transfer_all(), ec);
if (ec)
{

View File

@ -16,7 +16,7 @@ int connect_handler_called = 0;
int handler_called = 0;
int data_size = 0;
int http_status = 0;
asio::error_code error_code;
error_code g_error_code;
char data_buffer[4000];
void print_http_header(http_parser const& p)
@ -38,11 +38,11 @@ void http_connect_handler(http_connection& c)
TEST_CHECK(c.socket().remote_endpoint().address() == address::from_string("127.0.0.1"));
}
void http_handler(asio::error_code const& ec, http_parser const& parser, char const* data, int size)
void http_handler(error_code const& ec, http_parser const& parser, char const* data, int size)
{
++handler_called;
data_size = size;
error_code = ec;
g_error_code = ec;
if (parser.header_finished())
{
@ -63,11 +63,11 @@ void reset_globals()
handler_called = 0;
data_size = 0;
http_status = 0;
error_code = asio::error_code();
g_error_code = error_code();
}
void run_test(std::string const& url, int size, int status, int connected
, boost::optional<asio::error_code> ec, proxy_settings const& ps)
, boost::optional<error_code> ec, proxy_settings const& ps)
{
reset_globals();
@ -83,11 +83,11 @@ void run_test(std::string const& url, int size, int status, int connected
std::cerr << "handler_called: " << handler_called << std::endl;
std::cerr << "status: " << http_status << std::endl;
std::cerr << "size: " << data_size << std::endl;
std::cerr << "error_code: " << error_code.message() << std::endl;
std::cerr << "error_code: " << g_error_code.message() << std::endl;
TEST_CHECK(connect_handler_called == connected);
TEST_CHECK(handler_called == 1);
TEST_CHECK(data_size == size || size == -1);
TEST_CHECK(!ec || error_code == *ec);
TEST_CHECK(!ec || g_error_code == *ec);
TEST_CHECK(http_status == status || status == -1);
}
@ -102,11 +102,11 @@ void run_suite(std::string const& protocol, proxy_settings const& ps)
std::cout << "\n\n********************** using " << test_name[ps.type]
<< " proxy **********************\n" << std::endl;
typedef boost::optional<asio::error_code> err;
run_test(protocol + "://127.0.0.1:8001/redirect", 3216, 200, 2, asio::error_code(), ps);
run_test(protocol + "://127.0.0.1:8001/infinite_redirect", 0, 301, 6, asio::error_code(), ps);
run_test(protocol + "://127.0.0.1:8001/test_file", 3216, 200, 1, asio::error_code(), ps);
run_test(protocol + "://127.0.0.1:8001/test_file.gz", 3216, 200, 1, asio::error_code(), ps);
typedef boost::optional<error_code> err;
run_test(protocol + "://127.0.0.1:8001/redirect", 3216, 200, 2, error_code(), ps);
run_test(protocol + "://127.0.0.1:8001/infinite_redirect", 0, 301, 6, error_code(), ps);
run_test(protocol + "://127.0.0.1:8001/test_file", 3216, 200, 1, error_code(), ps);
run_test(protocol + "://127.0.0.1:8001/test_file.gz", 3216, 200, 1, error_code(), ps);
run_test(protocol + "://127.0.0.1:8001/non-existing-file", -1, 404, 1, err(), ps);
// if we're going through an http proxy, we won't get the same error as if the hostname
// resolution failed

View File

@ -280,7 +280,7 @@ int test_main()
// test network functions
asio::error_code ec;
error_code ec;
TEST_CHECK(is_local(address::from_string("192.168.0.1", ec)));
TEST_CHECK(is_local(address::from_string("10.1.1.56", ec)));
TEST_CHECK(!is_local(address::from_string("14.14.251.63", ec)));

View File

@ -14,7 +14,7 @@ void callback(int mapping, int port, std::string const& err)
int main(int argc, char* argv[])
{
io_service ios;
libtorrent::io_service ios;
std::string user_agent = "test agent";
if (argc != 3)
@ -27,9 +27,9 @@ int main(int argc, char* argv[])
boost::intrusive_ptr<upnp> upnp_handler = new upnp(ios, cc, address_v4(), user_agent, &callback, true);
upnp_handler->discover_device();
deadline_timer timer(ios);
libtorrent::deadline_timer timer(ios);
timer.expires_from_now(seconds(2));
timer.async_wait(boost::bind(&io_service::stop, boost::ref(ios)));
timer.async_wait(boost::bind(&libtorrent::io_service::stop, boost::ref(ios)));
std::cerr << "broadcasting for UPnP device" << std::endl;
@ -39,7 +39,7 @@ int main(int argc, char* argv[])
upnp_handler->add_mapping(upnp::tcp, atoi(argv[1]), atoi(argv[1]));
upnp_handler->add_mapping(upnp::udp, atoi(argv[2]), atoi(argv[2]));
timer.expires_from_now(seconds(10));
timer.async_wait(boost::bind(&io_service::stop, boost::ref(ios)));
timer.async_wait(boost::bind(&libtorrent::io_service::stop, boost::ref(ios)));
std::cerr << "mapping ports TCP: " << argv[1]
<< " UDP: " << argv[2] << std::endl;