switched over to asio from boost-1.35
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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)));
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user