more beos fixes

This commit is contained in:
Arvid Norberg 2009-12-15 13:11:07 +00:00
parent cebcbc3eeb
commit 96cedc9b5f
23 changed files with 92 additions and 36 deletions

View File

@ -135,11 +135,12 @@ bool sleep_and_input(char* c, int sleep)
FD_ZERO(&set); FD_ZERO(&set);
FD_SET(0, &set); FD_SET(0, &set);
timeval tv = {sleep, 0}; timeval tv = {sleep, 0};
if (select(1, &set, 0, 0, &tv) > 0) // if (select(1, &set, 0, 0, &tv) > 0)
{ // {
*c = getc(stdin); // *c = getc(stdin);
return true; // return true;
} // }
libtorrent::sleep(500);
return false; return false;
} }
@ -752,6 +753,11 @@ int main(int argc, char* argv[])
using namespace libtorrent; using namespace libtorrent;
session_settings settings; session_settings settings;
{
mutex m;
mutex::scoped_lock l(m);
}
settings.user_agent = "client_test/" LIBTORRENT_VERSION; settings.user_agent = "client_test/" LIBTORRENT_VERSION;
settings.auto_upload_slots_rate_based = true; settings.auto_upload_slots_rate_based = true;
//settings.announce_to_all_trackers = true; //settings.announce_to_all_trackers = true;

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cstring> #include <cstring>
#include "libtorrent/invariant_check.hpp" #include "libtorrent/invariant_check.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include <cstdlib> // malloc/free/realloc
namespace libtorrent { namespace libtorrent {

View File

@ -188,7 +188,9 @@ namespace libtorrent
torrent_handle find_torrent(sha1_hash const& info_hash) const; torrent_handle find_torrent(sha1_hash const& info_hash) const;
// all torrent_handles must be destructed before the session is destructed! // all torrent_handles must be destructed before the session is destructed!
#ifndef BOOST_NO_EXCEPTIONS
torrent_handle add_torrent(add_torrent_params const& params); torrent_handle add_torrent(add_torrent_params const& params);
#endif
torrent_handle add_torrent(add_torrent_params const& params, error_code& ec); torrent_handle add_torrent(add_torrent_params const& params, error_code& ec);
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE

View File

@ -77,10 +77,11 @@ namespace libtorrent
#elif defined TORRENT_WINDOWS #elif defined TORRENT_WINDOWS
return (char*)VirtualAlloc(0, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); return (char*)VirtualAlloc(0, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
#elif defined TORRENT_BEOS #elif defined TORRENT_BEOS
// we could potentially use create_area() here, but void* ret = 0;
// you can't free it through its pointer, you need to area_id id = create_area("", &ret, B_ANY_ADDRESS
// associate the area_id with the pointer somehow , (bytes + page_size() - 1) & (page_size()-1), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
return (char*)::malloc(bytes); if (id < B_OK) return 0;
return (char*)ret;
#else #else
return (char*)valloc(bytes); return (char*)valloc(bytes);
#endif #endif
@ -91,7 +92,9 @@ namespace libtorrent
#ifdef TORRENT_WINDOWS #ifdef TORRENT_WINDOWS
VirtualFree(block, 0, MEM_RELEASE); VirtualFree(block, 0, MEM_RELEASE);
#elif defined TORRENT_BEOS #elif defined TORRENT_BEOS
return ::free(block); area_id id = area_for(block);
if (id < B_OK) return;
delete_area(id);
#else #else
::free(block); ::free(block);
#endif #endif

View File

@ -31,7 +31,6 @@ POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <fstream> #include <fstream>
#include <sstream>
#include "libtorrent/session.hpp" #include "libtorrent/session.hpp"
#include "libtorrent/hasher.hpp" #include "libtorrent/hasher.hpp"
@ -45,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/alert_types.hpp" #include "libtorrent/alert_types.hpp"
#include "libtorrent/create_torrent.hpp" #include "libtorrent/create_torrent.hpp"
#include "libtorrent/socket_io.hpp" // print_endpoint
using namespace libtorrent; using namespace libtorrent;
@ -55,10 +55,10 @@ void report_failure(char const* err, char const* file, int line)
#ifdef TORRENT_WINDOWS #ifdef TORRENT_WINDOWS
HANDLE console = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, 0, CONSOLE_TEXTMODE_BUFFER, 0); HANDLE console = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, 0, CONSOLE_TEXTMODE_BUFFER, 0);
SetConsoleTextAttribute(console, FOREGROUND_RED); SetConsoleTextAttribute(console, FOREGROUND_RED);
std::cerr << "\n**** " << file << ":" << line << " \"" << err << " ****\n\n"; fprintf(stderr, "\n**** %s:%d \"%s\" ****\n\n", file, line, err);
CloseHandle(console); CloseHandle(console);
#else #else
std::cerr << "\033[31m" << file << ":" << line << " \"" << err << "\"\033[0m\n"; fprintf(stderr, "\033[31m %s:%d \"%s\"\033[0m\n", file, line, err);
#endif #endif
tests_failure = true; tests_failure = true;
} }
@ -79,13 +79,13 @@ bool print_alerts(libtorrent::session& ses, char const* name
if (predicate && predicate(a.get())) ret = true; if (predicate && predicate(a.get())) ret = true;
if (peer_disconnected_alert* p = dynamic_cast<peer_disconnected_alert*>(a.get())) if (peer_disconnected_alert* p = dynamic_cast<peer_disconnected_alert*>(a.get()))
{ {
std::cerr << name << "(" << p->ip << "): " << p->message() << "\n"; fprintf(stderr, "%s(%s): %s\n", name, print_endpoint(p->ip).c_str(), p->message().c_str());
} }
else if (a->message() != "block downloading" else if (a->message() != "block downloading"
&& a->message() != "block finished" && a->message() != "block finished"
&& a->message() != "piece finished") && a->message() != "piece finished")
{ {
std::cerr << name << ": " << a->message() << "\n"; fprintf(stderr, "%s: %s\n", name, p->message().c_str());
} }
TEST_CHECK(dynamic_cast<fastresume_rejected_alert*>(a.get()) == 0 || allow_failed_fastresume); TEST_CHECK(dynamic_cast<fastresume_rejected_alert*>(a.get()) == 0 || allow_failed_fastresume);
@ -202,7 +202,9 @@ boost::intrusive_ptr<torrent_info> create_torrent(std::ostream* file, int piece_
std::back_insert_iterator<std::vector<char> > out(tmp); std::back_insert_iterator<std::vector<char> > out(tmp);
bencode(out, t.generate()); bencode(out, t.generate());
return boost::intrusive_ptr<torrent_info>(new torrent_info(&tmp[0], tmp.size())); error_code ec;
return boost::intrusive_ptr<torrent_info>(new torrent_info(
&tmp[0], tmp.size(), ec));
} }
boost::tuple<torrent_handle, torrent_handle, torrent_handle> boost::tuple<torrent_handle, torrent_handle, torrent_handle>
@ -254,7 +256,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
} }
char ih_hex[41]; char ih_hex[41];
to_hex((char const*)&t->info_hash()[0], 20, ih_hex); to_hex((char const*)&t->info_hash()[0], 20, ih_hex);
std::cerr << "generated torrent: " << ih_hex << " ./tmp1" << suffix << "/temporary" << std::endl; fprintf(stderr, "generated torrent: %s ./tmp1%s/temporary\n", ih_hex, suffix.c_str());
} }
else else
{ {
@ -269,7 +271,8 @@ setup_transfer(session* ses1, session* ses2, session* ses3
if (p) param = *p; if (p) param = *p;
param.ti = clone_ptr(t); param.ti = clone_ptr(t);
param.save_path = "./tmp1" + suffix; param.save_path = "./tmp1" + suffix;
torrent_handle tor1 = ses1->add_torrent(param); error_code ec;
torrent_handle tor1 = ses1->add_torrent(param, ec);
tor1.super_seeding(super_seeding); tor1.super_seeding(super_seeding);
TEST_CHECK(!ses1->get_torrents().empty()); TEST_CHECK(!ses1->get_torrents().empty());
torrent_handle tor2; torrent_handle tor2;
@ -282,7 +285,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
{ {
param.ti = clone_ptr(t); param.ti = clone_ptr(t);
param.save_path = "./tmp3" + suffix; param.save_path = "./tmp3" + suffix;
tor3 = ses3->add_torrent(param); tor3 = ses3->add_torrent(param, ec);
TEST_CHECK(!ses3->get_torrents().empty()); TEST_CHECK(!ses3->get_torrents().empty());
} }
@ -297,7 +300,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
} }
param.save_path = "./tmp2" + suffix; param.save_path = "./tmp2" + suffix;
tor2 = ses2->add_torrent(param); tor2 = ses2->add_torrent(param, ec);
TEST_CHECK(!ses2->get_torrents().empty()); TEST_CHECK(!ses2->get_torrents().empty());
assert(ses1->get_torrents().size() == 1); assert(ses1->get_torrents().size() == 1);
@ -307,7 +310,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
if (connect_peers) if (connect_peers)
{ {
std::cerr << "connecting peer\n"; fprintf(stderr, "connecting peer\n");
error_code ec; error_code ec;
tor1.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec) tor1.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec)
, ses2->listen_port())); , ses2->listen_port()));

View File

@ -35,6 +35,10 @@ POSSIBILITY OF SUCH DAMAGE.
void report_failure(char const* str, char const* file, int line); void report_failure(char const* str, char const* file, int line);
#include <boost/config.hpp>
#include <exception>
#include <sstream>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define COUNTER_GUARD(x) #define COUNTER_GUARD(x)
#else #else
@ -51,6 +55,17 @@ void report_failure(char const* str, char const* file, int line);
#define TEST_REPORT_AUX(x, line, file) \ #define TEST_REPORT_AUX(x, line, file) \
report_failure(x, line, file) report_failure(x, line, file)
#ifdef BOOST_NO_EXCEPTIONS
#define TEST_CHECK(x) \
if (!(x)) \
TEST_REPORT_AUX("TEST_CHECK failed: \"" #x "\"", __FILE__, __LINE__);
#define TEST_EQUAL(x, y) \
if (x != y) { \
std::stringstream s; \
s << "TEST_EQUAL_ERROR: " << #x << ": " << x << " expected: " << y << std::endl; \
TEST_REPORT_AUX(s.str().c_str(), __FILE__, __LINE__); \
}
#else
#define TEST_CHECK(x) \ #define TEST_CHECK(x) \
try \ try \
{ \ { \
@ -82,6 +97,7 @@ void report_failure(char const* str, char const* file, int line);
{ \ { \
TEST_ERROR("Exception thrown: " #x); \ TEST_ERROR("Exception thrown: " #x); \
} }
#endif
#define TEST_ERROR(x) \ #define TEST_ERROR(x) \
TEST_REPORT_AUX((std::string("ERROR: \"") + x + "\"").c_str(), __FILE__, __LINE__) TEST_REPORT_AUX((std::string("ERROR: \"") + x + "\"").c_str(), __FILE__, __LINE__)

View File

@ -4,6 +4,7 @@
#include "libtorrent/alert_types.hpp" #include "libtorrent/alert_types.hpp"
#include "libtorrent/thread.hpp" #include "libtorrent/thread.hpp"
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <iostream>
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"

View File

@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session.hpp" #include "libtorrent/session.hpp"
#include "libtorrent/kademlia/node.hpp" // for verify_message #include "libtorrent/kademlia/node.hpp" // for verify_message
#include "libtorrent/bencode.hpp" #include "libtorrent/bencode.hpp"
#include <iostream>
#include "test.hpp" #include "test.hpp"

View File

@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io.hpp" #include "libtorrent/io.hpp"
#include <cstring> #include <cstring>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <iostream>
using namespace libtorrent; using namespace libtorrent;
@ -161,7 +162,8 @@ void test_reject_fast()
boost::intrusive_ptr<torrent_info> t = ::create_torrent(); boost::intrusive_ptr<torrent_info> t = ::create_torrent();
sha1_hash ih = t->info_hash(); sha1_hash ih = t->info_hash();
session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48900, 49000), "0.0.0.0", 0); session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48900, 49000), "0.0.0.0", 0);
ses1.add_torrent(t, "./tmp1_fast"); error_code ec;
ses1.add_torrent(t, "./tmp1_fast", ec);
test_sleep(2000); test_sleep(2000);
@ -218,12 +220,12 @@ void test_respect_suggest()
boost::intrusive_ptr<torrent_info> t = ::create_torrent(); boost::intrusive_ptr<torrent_info> t = ::create_torrent();
sha1_hash ih = t->info_hash(); sha1_hash ih = t->info_hash();
session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48900, 49000), "0.0.0.0", 0); session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48900, 49000), "0.0.0.0", 0);
ses1.add_torrent(t, "./tmp1_fast"); error_code ec;
ses1.add_torrent(t, "./tmp1_fast", ec);
test_sleep(2000); test_sleep(2000);
io_service ios; io_service ios;
error_code ec;
stream_socket s(ios); stream_socket s(ios);
s.connect(tcp::endpoint(address::from_string("127.0.0.1", ec), ses1.listen_port()), ec); s.connect(tcp::endpoint(address::from_string("127.0.0.1", ec), ses1.listen_port()), ec);

View File

@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/hasher.hpp" #include "libtorrent/hasher.hpp"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include "libtorrent/escape_string.hpp" // from_hex
#include "test.hpp" #include "test.hpp"

View File

@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include <fstream> #include <fstream>
#include <iostream>
#include <boost/optional.hpp> #include <boost/optional.hpp>
using namespace libtorrent; using namespace libtorrent;
@ -67,7 +68,8 @@ void http_connect_handler(http_connection& c)
++connect_handler_called; ++connect_handler_called;
TEST_CHECK(c.socket().is_open()); TEST_CHECK(c.socket().is_open());
error_code ec; error_code ec;
std::cerr << "connected to: " << c.socket().remote_endpoint(ec) << std::endl; std::cerr << "connected to: " << print_endpoint(c.socket().remote_endpoint(ec))
<< std::endl;
TEST_CHECK(c.socket().remote_endpoint(ec).address() == address::from_string("127.0.0.1", ec)); TEST_CHECK(c.socket().remote_endpoint(ec).address() == address::from_string("127.0.0.1", ec));
} }

View File

@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include <iostream>
void test_lsd() void test_lsd()
{ {

View File

@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include "libtorrent/extensions/metadata_transfer.hpp" #include "libtorrent/extensions/metadata_transfer.hpp"
#include "libtorrent/extensions/ut_metadata.hpp" #include "libtorrent/extensions/ut_metadata.hpp"
#include <iostream>
using boost::tuples::ignore; using boost::tuples::ignore;

View File

@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include <iostream>
void test_pex() void test_pex()
{ {

View File

@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <set> #include <set>
#include <iostream>
#include "test.hpp" #include "test.hpp"

View File

@ -52,6 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp> #include <boost/tuple/tuple_comparison.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <iostream>
#include "test.hpp" #include "test.hpp"

View File

@ -43,6 +43,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include <iostream>
#include <fstream>
using namespace libtorrent; using namespace libtorrent;
@ -732,7 +734,8 @@ void test_fastresume(std::string const& test_path)
session ses(fingerprint(" ", 0,0,0,0), 0); session ses(fingerprint(" ", 0,0,0,0), 0);
ses.set_alert_mask(alert::all_categories); ses.set_alert_mask(alert::all_categories);
torrent_handle h = ses.add_torrent(boost::intrusive_ptr<torrent_info>(new torrent_info(*t)) error_code ec;
torrent_handle h = ses.add_torrent(boost::intrusive_ptr<torrent_info>(new torrent_info(*t), ec)
, combine_path(test_path, "tmp1"), entry(), storage_mode_compact); , combine_path(test_path, "tmp1"), entry(), storage_mode_compact);
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
@ -804,7 +807,7 @@ void test_rename_file_in_fastresume(std::string const& test_path)
session ses(fingerprint(" ", 0,0,0,0), 0); session ses(fingerprint(" ", 0,0,0,0), 0);
ses.set_alert_mask(alert::all_categories); ses.set_alert_mask(alert::all_categories);
torrent_handle h = ses.add_torrent(boost::intrusive_ptr<torrent_info>(new torrent_info(*t)) torrent_handle h = ses.add_torrent(boost::intrusive_ptr<torrent_info>(new torrent_info(*t, ec))
, combine_path(test_path, "tmp2"), entry() , combine_path(test_path, "tmp2"), entry()
, storage_mode_compact); , storage_mode_compact);

View File

@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include <iostream>
void test_swarm(bool super_seeding = false, bool strict = false, bool seed_mode = false, bool time_critical = false) void test_swarm(bool super_seeding = false, bool strict = false, bool seed_mode = false, bool time_critical = false)
{ {

View File

@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alert_types.hpp" #include "libtorrent/alert_types.hpp"
#include "libtorrent/thread.hpp" #include "libtorrent/thread.hpp"
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <iostream>
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
@ -52,7 +53,8 @@ void test_running_torrent(boost::intrusive_ptr<torrent_info> info, size_type fil
add_torrent_params p; add_torrent_params p;
p.ti = info; p.ti = info;
p.save_path = "."; p.save_path = ".";
torrent_handle h = ses.add_torrent(p); error_code ec;
torrent_handle h = ses.add_torrent(p, ec);
test_sleep(500); test_sleep(500);
torrent_status st = h.status(); torrent_status st = h.status();
@ -151,7 +153,8 @@ int test_main()
std::vector<char> tmp; std::vector<char> tmp;
std::back_insert_iterator<std::vector<char> > out(tmp); std::back_insert_iterator<std::vector<char> > out(tmp);
bencode(out, t.generate()); bencode(out, t.generate());
boost::intrusive_ptr<torrent_info> info(new torrent_info(&tmp[0], tmp.size())); error_code ec;
boost::intrusive_ptr<torrent_info> info(new torrent_info(&tmp[0], tmp.size(), ec));
TEST_CHECK(info->num_pieces() > 0); TEST_CHECK(info->num_pieces() > 0);
test_running_torrent(info, file_size); test_running_torrent(info, file_size);
@ -167,7 +170,8 @@ int test_main()
std::vector<char> tmp; std::vector<char> tmp;
std::back_insert_iterator<std::vector<char> > out(tmp); std::back_insert_iterator<std::vector<char> > out(tmp);
bencode(out, t.generate()); bencode(out, t.generate());
boost::intrusive_ptr<torrent_info> info(new torrent_info(&tmp[0], tmp.size())); error_code ec;
boost::intrusive_ptr<torrent_info> info(new torrent_info(&tmp[0], tmp.size(), ec));
test_running_torrent(info, 0); test_running_torrent(info, 0);
} }

View File

@ -55,9 +55,10 @@ int test_main()
add_torrent_params atp; add_torrent_params atp;
atp.info_hash = sha1_hash("12345678901234567890"); atp.info_hash = sha1_hash("12345678901234567890");
atp.save_path = "./"; atp.save_path = "./";
torrent_handle tor1 = ses1.add_torrent(atp); error_code ec;
torrent_handle tor1 = ses1.add_torrent(atp, ec);
atp.tracker_url = "http://test.non-existent.com/announce"; atp.tracker_url = "http://test.non-existent.com/announce";
torrent_handle tor2 = ses2.add_torrent(atp); torrent_handle tor2 = ses2.add_torrent(atp, ec);
tor2.connect_peer(tcp::endpoint(address_v4::from_string("127.0.0.1"), ses1.listen_port())); tor2.connect_peer(tcp::endpoint(address_v4::from_string("127.0.0.1"), ses1.listen_port()));
for (int i = 0; i < 130; ++i) for (int i = 0; i < 130; ++i)

View File

@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include <fstream> #include <fstream>
#include <iostream>
using namespace libtorrent; using namespace libtorrent;
using boost::tuples::ignore; using boost::tuples::ignore;
@ -399,7 +400,7 @@ void test_transfer(bool test_disk_full = false, bool test_allowed_fast = false)
p.ti = t; p.ti = t;
p.save_path = "./tmp2_transfer_moved"; p.save_path = "./tmp2_transfer_moved";
p.resume_data = &resume_data; p.resume_data = &resume_data;
tor2 = ses2.add_torrent(p); tor2 = ses2.add_torrent(p, ec);
ses2.set_alert_mask(alert::all_categories & ~alert::progress_notification); ses2.set_alert_mask(alert::all_categories & ~alert::progress_notification);
tor2.prioritize_pieces(priorities); tor2.prioritize_pieces(priorities);
std::cout << "resetting priorities" << std::endl; std::cout << "resetting priorities" << std::endl;

View File

@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/ref.hpp> #include <boost/ref.hpp>
#include <boost/intrusive_ptr.hpp> #include <boost/intrusive_ptr.hpp>
#include <iostream>
using namespace libtorrent; using namespace libtorrent;
@ -145,7 +146,8 @@ void incoming_msearch(udp::endpoint const& from, char* buffer
p.incoming(buffer::const_interval(buffer, buffer + size), error); p.incoming(buffer::const_interval(buffer, buffer + size), error);
if (error || !p.header_finished()) if (error || !p.header_finished())
{ {
std::cerr << "*** malformed HTTP from " << from << std::endl; std::cerr << "*** malformed HTTP from "
<< print_endpoint(from) << std::endl;
return; return;
} }

View File

@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/thread.hpp" #include "libtorrent/thread.hpp"
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <fstream> #include <fstream>
#include <iostream>
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
@ -77,7 +78,7 @@ void test_transfer(boost::intrusive_ptr<torrent_info> torrent_file, int proxy)
ses.set_web_seed_proxy(ps); ses.set_web_seed_proxy(ps);
} }
torrent_handle th = ses.add_torrent(*torrent_file, "./tmp2_web_seed"); torrent_handle th = ses.add_torrent(*torrent_file, "./tmp2_web_seed", ec);
std::vector<announce_entry> empty; std::vector<announce_entry> empty;
th.replace_trackers(empty); th.replace_trackers(empty);
@ -170,7 +171,7 @@ int test_main()
start_web_server(8000); start_web_server(8000);
// calculate the hash for all pieces // calculate the hash for all pieces
set_piece_hashes(t, "./tmp1_web_seed"); set_piece_hashes(t, "./tmp1_web_seed", ec);
boost::intrusive_ptr<torrent_info> torrent_file(new torrent_info(t.generate())); boost::intrusive_ptr<torrent_info> torrent_file(new torrent_info(t.generate()));
for (int i = 0; i < 6; ++i) for (int i = 0; i < 6; ++i)