exception fixes

This commit is contained in:
Arvid Norberg 2008-11-05 05:39:18 +00:00
parent 359500da58
commit 19c66a1826
4 changed files with 38 additions and 20 deletions

View File

@ -60,11 +60,13 @@ namespace libtorrent
address guess_local_address(io_service&);
}
static error_code ec;
lsd::lsd(io_service& ios, address const& listen_interface
, peer_callback_t const& cb)
: m_callback(cb)
, m_retry_count(1)
, m_socket(ios, udp::endpoint(address_v4::from_string("239.192.152.143"), 6771)
, m_socket(ios, udp::endpoint(address_v4::from_string("239.192.152.143", ec), 6771)
, bind(&lsd::on_announce, self(), _1, _2, _3))
, m_broadcast_timer(ios)
, m_disabled(false)

View File

@ -157,7 +157,6 @@ namespace aux {
#endif
, m_tracker_manager(*this, m_tracker_proxy)
, m_listen_port_retries(listen_port_range.second - listen_port_range.first)
, m_listen_interface(address::from_string(listen_interface), listen_port_range.first)
, m_abort(false)
, m_paused(false)
, m_max_uploads(8)
@ -189,6 +188,10 @@ namespace aux {
, m_total_failed_bytes(0)
, m_total_redundant_bytes(0)
{
error_code ec;
m_listen_interface = tcp::endpoint(address::from_string(listen_interface, ec), listen_port_range.first);
TORRENT_ASSERT(!ec);
m_tcp_mapping[0] = -1;
m_tcp_mapping[1] = -1;
m_udp_mapping[0] = -1;
@ -271,7 +274,6 @@ namespace aux {
*i = printable[rand() % (sizeof(printable)-1)];
}
error_code ec;
m_timer.expires_from_now(seconds(1), ec);
m_timer.async_wait(
bind(&session_impl::second_tick, this, _1));
@ -1675,23 +1677,17 @@ namespace aux {
do
{
#ifndef BOOST_NO_EXCEPTIONS
try
{
#endif
m_io_service.run();
TORRENT_ASSERT(m_abort == true);
#ifndef BOOST_NO_EXCEPTIONS
}
catch (std::exception& e)
error_code ec;
m_io_service.run(ec);
TORRENT_ASSERT(m_abort == true);
if (ec)
{
#ifndef NDEBUG
std::cerr << e.what() << "\n";
std::string err = e.what();
std::cerr << ec.message() << "\n";
std::string err = ec.message();
#endif
TORRENT_ASSERT(false);
}
#endif
}
while (!m_abort);
@ -1944,7 +1940,18 @@ namespace aux {
tcp::endpoint new_interface;
if (net_interface && std::strlen(net_interface) > 0)
new_interface = tcp::endpoint(address::from_string(net_interface), port_range.first);
{
error_code ec;
new_interface = tcp::endpoint(address::from_string(net_interface, ec), port_range.first);
if (ec)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() << "listen_on: " << net_interface
<< " failed: " << ec.message() << "\n";
#endif
return false;
}
}
else
new_interface = tcp::endpoint(address_v4::any(), port_range.first);

View File

@ -571,7 +571,9 @@ namespace libtorrent
std::string ip = e->dict_find_string_value("ip");
int port = e->dict_find_int_value("port");
if (ip.empty() || port == 0) continue;
tcp::endpoint a(address::from_string(ip), (unsigned short)port);
error_code ec;
tcp::endpoint a(address::from_string(ip, ec), (unsigned short)port);
if (ec) continue;
m_policy.peer_from_tracker(a, id, peer_info::resume_data, 0);
}
}
@ -588,7 +590,9 @@ namespace libtorrent
std::string ip = e->dict_find_string_value("ip");
int port = e->dict_find_int_value("port");
if (ip.empty() || port == 0) continue;
tcp::endpoint a(address::from_string(ip), (unsigned short)port);
error_code ec;
tcp::endpoint a(address::from_string(ip, ec), (unsigned short)port);
if (ec) continue;
policy::peer* p = m_policy.peer_from_tracker(a, id, peer_info::resume_data, 0);
if (p) p->banned = true;
}
@ -792,7 +796,10 @@ namespace libtorrent
{
INVARIANT_CHECK;
m_net_interface = tcp::endpoint(address::from_string(net_interface), 0);
error_code ec;
address a(address::from_string(net_interface, ec));
if (ec) return;
m_net_interface = tcp::endpoint(a, 0);
}
void torrent::on_tracker_announce_disp(boost::weak_ptr<torrent> p

View File

@ -55,6 +55,8 @@ POSSIBILITY OF SUCH DAMAGE.
using boost::bind;
using namespace libtorrent;
static error_code ec;
upnp::upnp(io_service& ios, connection_queue& cc
, address const& listen_interface, std::string const& user_agent
, portmap_callback_t const& cb, bool ignore_nonrouters, void* state)
@ -62,7 +64,7 @@ upnp::upnp(io_service& ios, connection_queue& cc
, m_callback(cb)
, m_retry_count(0)
, m_io_service(ios)
, m_socket(ios, udp::endpoint(address_v4::from_string("239.255.255.250"), 1900)
, m_socket(ios, udp::endpoint(address_v4::from_string("239.255.255.250", ec), 1900)
, bind(&upnp::on_reply, self(), _1, _2, _3), false)
, m_broadcast_timer(ios)
, m_refresh_timer(ios)