fixed tracker error race condition

This commit is contained in:
Arvid Norberg 2009-06-23 01:52:44 +00:00
parent 5ea4c73409
commit fffda3c738
2 changed files with 5 additions and 2 deletions

View File

@ -244,9 +244,10 @@ namespace libtorrent
}
else
{
// we need to post the error to avoid deadlock
if (boost::shared_ptr<request_callback> r = c.lock())
r->tracker_request_error(req, -1, "unknown protocol in tracker url: "
+ req.url);
ios.post(boost::bind(&request_callback::tracker_request_error, r, req, -1
, "unknown protocol in tracker url: " + req.url));
return;
}

View File

@ -217,6 +217,7 @@ boost::intrusive_ptr<torrent_info> create_torrent(std::ostream* file, int piece_
char const* tracker_url = "http://non-existent-name.com/announce";
// excercise the path when encountering invalid urls
char const* invalid_tracker_url = "http:";
char const* invalid_tracker_protocol = "foo://non/existent-name.com/announce";
using namespace boost::filesystem;
@ -226,6 +227,7 @@ boost::intrusive_ptr<torrent_info> create_torrent(std::ostream* file, int piece_
libtorrent::create_torrent t(fs, piece_size);
t.add_tracker(tracker_url);
t.add_tracker(invalid_tracker_url);
t.add_tracker(invalid_tracker_protocol);
std::vector<char> piece(piece_size);
for (int i = 0; i < int(piece.size()); ++i)