more exception defines

This commit is contained in:
Arvid Norberg 2008-11-03 04:23:16 +00:00
parent dd97d49753
commit 19660306e0
3 changed files with 11 additions and 2 deletions

View File

@ -254,8 +254,10 @@ void upnp::resend_request(error_code const& e)
// ask for it
rootdevice& d = const_cast<rootdevice&>(*i);
TORRENT_ASSERT(d.magic == 1337);
#ifndef BOOST_NO_EXCEPTIONS
try
{
#endif
std::stringstream msg;
msg << "connecting to: " << d.url;
log(msg.str());
@ -264,6 +266,7 @@ void upnp::resend_request(error_code const& e)
, m_cc, bind(&upnp::on_upnp_xml, self(), _1, _2
, boost::ref(d), _5)));
d.upnp_connection->get(d.url, seconds(30), 1);
#ifndef BOOST_NO_EXCEPTIONS
}
catch (std::exception& e)
{
@ -273,6 +276,7 @@ void upnp::resend_request(error_code const& e)
log(msg.str());
d.disabled = true;
}
#endif
}
}
}

View File

@ -44,10 +44,13 @@ void report_failure(char const* err, char const* file, int line)
int main()
{
#ifndef BOOST_NO_EXCEPTIONS
try
{
#endif
test_main();
return tests_failure ? 1 : 0;
#ifndef BOOST_NO_EXCEPTIONS
}
catch (std::exception const& e)
{
@ -59,5 +62,6 @@ int main()
std::cerr << "Terminated with unknown exception\n";
return 1;
}
#endif
}

View File

@ -65,7 +65,8 @@ int main(int argc, char* argv[])
upnp_handler->discover_device();
libtorrent::deadline_timer timer(ios);
timer.expires_from_now(seconds(2));
error_code ec;
timer.expires_from_now(seconds(2), ec);
timer.async_wait(boost::bind(&libtorrent::io_service::stop, boost::ref(ios)));
std::cerr << "broadcasting for UPnP device" << std::endl;
@ -75,7 +76,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.expires_from_now(seconds(10), ec);
timer.async_wait(boost::bind(&libtorrent::io_service::stop, boost::ref(ios)));
std::cerr << "mapping ports TCP: " << argv[1]
<< " UDP: " << argv[2] << std::endl;