forked from premiere/premiere-libtorrent
made tracker_manager build without exception support
This commit is contained in:
parent
a279e8c9ec
commit
1e20940c31
|
@ -254,7 +254,8 @@ namespace libtorrent
|
||||||
|
|
||||||
int timeout = (std::min)(
|
int timeout = (std::min)(
|
||||||
m_read_timeout, (std::min)(m_completion_timeout, m_read_timeout));
|
m_read_timeout, (std::min)(m_completion_timeout, m_read_timeout));
|
||||||
m_timeout.expires_at(m_read_time + seconds(timeout));
|
asio::error_code ec;
|
||||||
|
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
|
||||||
m_timeout.async_wait(m_strand.wrap(bind(
|
m_timeout.async_wait(m_strand.wrap(bind(
|
||||||
&timeout_handler::timeout_callback, self(), _1)));
|
&timeout_handler::timeout_callback, self(), _1)));
|
||||||
}
|
}
|
||||||
|
@ -268,10 +269,11 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
m_completion_timeout = 0;
|
m_completion_timeout = 0;
|
||||||
m_timeout.cancel();
|
asio::error_code ec;
|
||||||
|
m_timeout.cancel(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timeout_handler::timeout_callback(asio::error_code const& error) try
|
void timeout_handler::timeout_callback(asio::error_code const& error)
|
||||||
{
|
{
|
||||||
if (error) return;
|
if (error) return;
|
||||||
if (m_completion_timeout == 0) return;
|
if (m_completion_timeout == 0) return;
|
||||||
|
@ -293,14 +295,11 @@ namespace libtorrent
|
||||||
|
|
||||||
int timeout = (std::min)(
|
int timeout = (std::min)(
|
||||||
m_read_timeout, (std::min)(m_completion_timeout, m_read_timeout));
|
m_read_timeout, (std::min)(m_completion_timeout, m_read_timeout));
|
||||||
m_timeout.expires_at(m_read_time + seconds(timeout));
|
asio::error_code ec;
|
||||||
|
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
|
||||||
m_timeout.async_wait(m_strand.wrap(
|
m_timeout.async_wait(m_strand.wrap(
|
||||||
bind(&timeout_handler::timeout_callback, self(), _1)));
|
bind(&timeout_handler::timeout_callback, self(), _1)));
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
|
||||||
{
|
|
||||||
TORRENT_ASSERT(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
tracker_connection::tracker_connection(
|
tracker_connection::tracker_connection(
|
||||||
tracker_manager& man
|
tracker_manager& man
|
||||||
|
@ -360,6 +359,10 @@ namespace libtorrent
|
||||||
std::string protocol; // should be http
|
std::string protocol; // should be http
|
||||||
int port = 80;
|
int port = 80;
|
||||||
|
|
||||||
|
std::string::iterator at;
|
||||||
|
std::string::iterator colon;
|
||||||
|
std::string::iterator port_pos;
|
||||||
|
|
||||||
// PARSE URL
|
// PARSE URL
|
||||||
std::string::iterator start = url.begin();
|
std::string::iterator start = url.begin();
|
||||||
// remove white spaces in front of the url
|
// remove white spaces in front of the url
|
||||||
|
@ -369,18 +372,18 @@ namespace libtorrent
|
||||||
= std::find(url.begin(), url.end(), ':');
|
= std::find(url.begin(), url.end(), ':');
|
||||||
protocol.assign(start, end);
|
protocol.assign(start, end);
|
||||||
|
|
||||||
if (end == url.end()) throw std::runtime_error("invalid url");
|
if (end == url.end()) goto exit;
|
||||||
++end;
|
++end;
|
||||||
if (end == url.end()) throw std::runtime_error("invalid url");
|
if (end == url.end()) goto exit;
|
||||||
if (*end != '/') throw std::runtime_error("invalid url");
|
if (*end != '/') goto exit;
|
||||||
++end;
|
++end;
|
||||||
if (end == url.end()) throw std::runtime_error("invalid url");
|
if (end == url.end()) goto exit;
|
||||||
if (*end != '/') throw std::runtime_error("invalid url");
|
if (*end != '/') goto exit;
|
||||||
++end;
|
++end;
|
||||||
start = end;
|
start = end;
|
||||||
|
|
||||||
std::string::iterator at = std::find(start, url.end(), '@');
|
at = std::find(start, url.end(), '@');
|
||||||
std::string::iterator colon = std::find(start, url.end(), ':');
|
colon = std::find(start, url.end(), ':');
|
||||||
end = std::find(start, url.end(), '/');
|
end = std::find(start, url.end(), '/');
|
||||||
|
|
||||||
if (at != url.end()
|
if (at != url.end()
|
||||||
|
@ -393,13 +396,11 @@ namespace libtorrent
|
||||||
++start;
|
++start;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::iterator port_pos;
|
|
||||||
|
|
||||||
// this is for IPv6 addresses
|
// this is for IPv6 addresses
|
||||||
if (start != url.end() && *start == '[')
|
if (start != url.end() && *start == '[')
|
||||||
{
|
{
|
||||||
port_pos = std::find(start, url.end(), ']');
|
port_pos = std::find(start, url.end(), ']');
|
||||||
if (port_pos == url.end()) throw std::runtime_error("invalid hostname syntax");
|
if (port_pos == url.end()) goto exit;
|
||||||
port_pos = std::find(port_pos, url.end(), ':');
|
port_pos = std::find(port_pos, url.end(), ':');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -411,15 +412,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
hostname.assign(start, port_pos);
|
hostname.assign(start, port_pos);
|
||||||
++port_pos;
|
++port_pos;
|
||||||
try
|
port = atoi(std::string(port_pos, end).c_str());
|
||||||
{
|
|
||||||
port = boost::lexical_cast<int>(std::string(port_pos, end));
|
|
||||||
}
|
|
||||||
catch(boost::bad_lexical_cast&)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("invalid url: \"" + url
|
|
||||||
+ "\", port number expected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -427,6 +420,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
start = end;
|
start = end;
|
||||||
|
exit:
|
||||||
return make_tuple(protocol, auth, hostname, port
|
return make_tuple(protocol, auth, hostname, port
|
||||||
, std::string(start, url.end()));
|
, std::string(start, url.end()));
|
||||||
}
|
}
|
||||||
|
@ -448,8 +442,6 @@ namespace libtorrent
|
||||||
if (m_abort && req.event != tracker_request::stopped)
|
if (m_abort && req.event != tracker_request::stopped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::string protocol;
|
std::string protocol;
|
||||||
std::string hostname;
|
std::string hostname;
|
||||||
int port;
|
int port;
|
||||||
|
@ -492,7 +484,9 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw std::runtime_error("unkown protocol in tracker url");
|
if (boost::shared_ptr<request_callback> r = c.lock())
|
||||||
|
r->tracker_request_error(req, -1, "unknown protocol in tracker url: "
|
||||||
|
+ protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connections.push_back(con);
|
m_connections.push_back(con);
|
||||||
|
@ -500,12 +494,6 @@ namespace libtorrent
|
||||||
boost::shared_ptr<request_callback> cb = con->requester();
|
boost::shared_ptr<request_callback> cb = con->requester();
|
||||||
if (cb) cb->m_manager = this;
|
if (cb) cb->m_manager = this;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
|
||||||
{
|
|
||||||
if (boost::shared_ptr<request_callback> r = c.lock())
|
|
||||||
r->tracker_request_error(req, -1, e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tracker_manager::abort_all_requests()
|
void tracker_manager::abort_all_requests()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue