cleaned up some exception handling and introduced macros like BOOST_TRY/BOOST_CATCH to make the optional exception handling nicer
This commit is contained in:
parent
5f5ba94462
commit
56937edf56
|
@ -233,10 +233,15 @@ int main(int argc, char* argv[])
|
|||
return 1;
|
||||
}
|
||||
int num_connections = atoi(argv[1]);
|
||||
address_v4 addr = address_v4::from_string(argv[2]);
|
||||
error_code ec;
|
||||
address_v4 addr = address_v4::from_string(argv[2], ec);
|
||||
if (ec)
|
||||
{
|
||||
fprintf(stderr, "ERROR RESOLVING %s: %s\n", argv[2], ec.message().c_str());
|
||||
return 1;
|
||||
}
|
||||
int port = atoi(argv[3]);
|
||||
tcp::endpoint ep(addr, port);
|
||||
error_code ec;
|
||||
torrent_info ti(argv[4], ec);
|
||||
if (ec)
|
||||
{
|
||||
|
@ -250,10 +255,16 @@ int main(int argc, char* argv[])
|
|||
conns.push_back(new peer_conn(ios, ti.num_pieces(), ti.piece_length() / 16 / 1024
|
||||
, ep, (char const*)&ti.info_hash()[0]));
|
||||
libtorrent::sleep(1);
|
||||
ios.poll_one();
|
||||
ios.poll_one(ec);
|
||||
if (ec)
|
||||
{
|
||||
fprintf(stderr, "ERROR: %s\n", ec.message().c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ios.run();
|
||||
ios.run(ec);
|
||||
if (ec) fprintf(stderr, "ERROR: %s\n", ec.message().c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -392,5 +392,15 @@ inline char* strdup(char const* str)
|
|||
}
|
||||
#endif
|
||||
|
||||
// for non-exception builds
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
#define TORRENT_TRY if (true)
|
||||
#define TORRENT_CATCH(x) else if (false)
|
||||
#else
|
||||
#define TORRENT_TRY try
|
||||
#define TORRENT_CATCH(x) catch(x)
|
||||
#endif // BOOST_NO_EXCEPTIONS
|
||||
|
||||
|
||||
#endif // TORRENT_CONFIG_HPP_INCLUDED
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/alert.hpp"
|
||||
#include "libtorrent/alert_types.hpp"
|
||||
#include "libtorrent/io_service.hpp"
|
||||
|
@ -381,7 +382,9 @@ namespace libtorrent {
|
|||
|
||||
while (!alerts.empty())
|
||||
{
|
||||
TORRENT_TRY {
|
||||
m_dispatch(std::auto_ptr<alert>(alerts.front()));
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
alerts.pop_front();
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +404,9 @@ namespace libtorrent {
|
|||
if (m_dispatch)
|
||||
{
|
||||
TORRENT_ASSERT(m_alerts.empty());
|
||||
TORRENT_TRY {
|
||||
m_dispatch(std::auto_ptr<alert>(alert_.clone()));
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
else if (m_alerts.size() < m_queue_size_limit || !alert_.discardable())
|
||||
{
|
||||
|
@ -414,13 +419,9 @@ namespace libtorrent {
|
|||
for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
|
||||
, end(m_ses_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->on_alert(&alert_);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace libtorrent
|
|||
{
|
||||
bool is_local(address const& a)
|
||||
{
|
||||
TORRENT_TRY {
|
||||
#if TORRENT_USE_IPV6
|
||||
if (a.is_v6()) return a.to_v6().is_link_local();
|
||||
#endif
|
||||
|
@ -69,15 +70,18 @@ namespace libtorrent
|
|||
|| (ip & 0xffff0000) == 0xc0a80000 // 192.168.x.x
|
||||
|| (ip & 0xffff0000) == 0xa9fe0000 // 169.254.x.x
|
||||
|| (ip & 0xff000000) == 0x7f000000); // 127.x.x.x
|
||||
} TORRENT_CATCH(std::exception& e) { return false; }
|
||||
}
|
||||
|
||||
bool is_loopback(address const& addr)
|
||||
{
|
||||
#if TORRENT_USE_IPV6
|
||||
TORRENT_TRY {
|
||||
if (addr.is_v4())
|
||||
return addr.to_v4() == address_v4::loopback();
|
||||
else
|
||||
return addr.to_v6() == address_v6::loopback();
|
||||
} TORRENT_CATCH(std::exception& e) { return false; }
|
||||
#else
|
||||
return addr.to_v4() == address_v4::loopback();
|
||||
#endif
|
||||
|
@ -86,10 +90,12 @@ namespace libtorrent
|
|||
bool is_multicast(address const& addr)
|
||||
{
|
||||
#if TORRENT_USE_IPV6
|
||||
TORRENT_TRY {
|
||||
if (addr.is_v4())
|
||||
return addr.to_v4().is_multicast();
|
||||
else
|
||||
return addr.to_v6().is_multicast();
|
||||
} TORRENT_CATCH(std::exception& e) { return false; }
|
||||
#else
|
||||
return addr.to_v4().is_multicast();
|
||||
#endif
|
||||
|
@ -97,6 +103,7 @@ namespace libtorrent
|
|||
|
||||
bool is_any(address const& addr)
|
||||
{
|
||||
TORRENT_TRY {
|
||||
#if TORRENT_USE_IPV6
|
||||
if (addr.is_v4())
|
||||
return addr.to_v4() == address_v4::any();
|
||||
|
@ -107,15 +114,18 @@ namespace libtorrent
|
|||
#else
|
||||
return addr.to_v4() == address_v4::any();
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception& e) { return false; }
|
||||
}
|
||||
|
||||
TORRENT_EXPORT bool is_teredo(address const& addr)
|
||||
{
|
||||
#if TORRENT_USE_IPV6
|
||||
TORRENT_TRY {
|
||||
if (!addr.is_v6()) return false;
|
||||
boost::uint8_t teredo_prefix[] = {0x20, 0x01, 0, 0};
|
||||
address_v6::bytes_type b = addr.to_v6().to_bytes();
|
||||
return memcmp(&b[0], teredo_prefix, 4) == 0;
|
||||
} TORRENT_CATCH(std::exception& e) { return false; }
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -124,9 +134,11 @@ namespace libtorrent
|
|||
bool supports_ipv6()
|
||||
{
|
||||
#if TORRENT_USE_IPV6
|
||||
TORRENT_TRY {
|
||||
error_code ec;
|
||||
address::from_string("::1", ec);
|
||||
return !ec;
|
||||
} TORRENT_CATCH(std::exception& e) { return false; }
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/invariant_check.hpp"
|
||||
#include "libtorrent/connection_queue.hpp"
|
||||
#include "libtorrent/io_service.hpp"
|
||||
|
@ -140,13 +141,9 @@ namespace libtorrent
|
|||
m_queue.pop_front();
|
||||
if (e.connecting) --m_num_connecting;
|
||||
l.unlock();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
e.on_timeout();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
l.lock();
|
||||
}
|
||||
}
|
||||
|
@ -236,13 +233,9 @@ namespace libtorrent
|
|||
while (!to_connect.empty())
|
||||
{
|
||||
entry& ent = to_connect.front();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
ent.on_connect(ent.ticket);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
to_connect.pop_front();
|
||||
}
|
||||
|
||||
|
@ -299,13 +292,9 @@ namespace libtorrent
|
|||
for (std::list<entry>::iterator i = timed_out.begin()
|
||||
, end(timed_out.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
i->on_timeout();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
|
||||
l.lock();
|
||||
|
|
|
@ -2303,15 +2303,11 @@ namespace libtorrent
|
|||
|
||||
ret = j.storage->check_files(j.piece, j.offset, j.error);
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
TORRENT_ASSERT(j.callback);
|
||||
if (j.callback && ret == piece_manager::need_full_check)
|
||||
post_callback(j.callback, j, ret);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
if (ret != piece_manager::need_full_check) break;
|
||||
}
|
||||
if (test_error(j))
|
||||
|
@ -2355,26 +2351,20 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception& e)
|
||||
TORRENT_CATCH(std::exception& e)
|
||||
{
|
||||
ret = -1;
|
||||
try
|
||||
{
|
||||
TORRENT_TRY {
|
||||
j.str = e.what();
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
catch (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(!j.storage || !j.storage->error());
|
||||
|
||||
// if (!j.callback) std::cerr << "DISK THREAD: no callback specified" << std::endl;
|
||||
// else std::cerr << "DISK THREAD: invoking callback" << std::endl;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
TORRENT_ASSERT(ret != -2 || j.error
|
||||
|| j.action == disk_io_job::hash);
|
||||
#if TORRENT_DISK_STATS
|
||||
|
@ -2383,12 +2373,9 @@ namespace libtorrent
|
|||
rename_buffer(j.buffer, "posted send buffer");
|
||||
#endif
|
||||
post_callback(j.callback, j, ret);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&)
|
||||
{
|
||||
} TORRENT_CATCH(std::exception&) {
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
|
|
@ -257,15 +257,10 @@ namespace libtorrent { namespace dht
|
|||
|
||||
if (bootstrap.type() == entry::dictionary_t)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
if (entry const* nodes = bootstrap.find_key("nodes"))
|
||||
read_endpoint_list<udp::endpoint>(nodes, initial_nodes);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
|
||||
error_code ec;
|
||||
|
|
|
@ -213,13 +213,9 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
|
|||
, port, ih_str.c_str());
|
||||
#endif
|
||||
// we got an announce, pass it on through the callback
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
m_callback(tcp::endpoint(from.address(), port), ih);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1070,11 +1070,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
TORRENT_TRY {
|
||||
(*i)->on_piece_pass(index);
|
||||
#else
|
||||
try { (*i)->on_piece_pass(index); } catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1087,11 +1085,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
TORRENT_TRY {
|
||||
(*i)->on_piece_failed(index);
|
||||
#else
|
||||
try { (*i)->on_piece_failed(index); } catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
if (is_disconnecting()) return;
|
||||
|
|
|
@ -1041,13 +1041,9 @@ namespace aux {
|
|||
for (ses_extension_list_t::const_iterator i = m_ses_extensions.begin()
|
||||
, end(m_ses_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->save_state(*eptr);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1143,13 +1139,9 @@ namespace aux {
|
|||
for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
|
||||
, end(m_ses_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->load_state(*e);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2512,13 +2504,9 @@ namespace aux {
|
|||
for (ses_extension_list_t::const_iterator i = m_ses_extensions.begin()
|
||||
, end(m_ses_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->on_tick();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3061,19 +3049,16 @@ namespace aux {
|
|||
connect_points /= num_seeds + 1;
|
||||
if (connect_points <= 0) connect_points = 1;
|
||||
t.give_connect_points(connect_points);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
TORRENT_TRY
|
||||
{
|
||||
#endif
|
||||
if (t.try_connect_peer())
|
||||
{
|
||||
--max_connections;
|
||||
--free_slots;
|
||||
steps_since_last_connect = 0;
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::bad_alloc&)
|
||||
TORRENT_CATCH(std::bad_alloc&)
|
||||
{
|
||||
// we ran out of memory trying to connect to a peer
|
||||
// lower the global limit to the number of peers
|
||||
|
@ -3081,7 +3066,6 @@ namespace aux {
|
|||
m_settings.connections_limit = num_connections();
|
||||
if (m_settings.connections_limit < 2) m_settings.connections_limit = 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
++m_next_connect_torrent;
|
||||
|
|
|
@ -2698,13 +2698,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->on_piece_pass(index);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2790,13 +2786,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->on_piece_failed(index);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3997,10 +3989,8 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
TORRENT_TRY
|
||||
{
|
||||
#endif
|
||||
// add the newly connected peer to this torrent's peer list
|
||||
m_connections.insert(boost::get_pointer(c));
|
||||
m_ses.m_connections.insert(c);
|
||||
|
@ -4018,16 +4008,15 @@ namespace libtorrent
|
|||
boost::bind(&peer_connection::on_connect, c, _1)
|
||||
, boost::bind(&peer_connection::on_timeout, c)
|
||||
, seconds(settings().peer_connect_timeout));
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception& e)
|
||||
TORRENT_CATCH (std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << e.what() << "\n";
|
||||
#endif
|
||||
c->disconnect(errors::no_error, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
|
@ -4799,14 +4788,10 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
boost::shared_ptr<peer_plugin> pp((*i)->new_connection(c.get()));
|
||||
if (pp) c->add_extension(pp);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -4819,17 +4804,14 @@ namespace libtorrent
|
|||
int timeout = settings().peer_connect_timeout;
|
||||
if (peerinfo) timeout += 3 * peerinfo->failcount;
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
TORRENT_TRY
|
||||
{
|
||||
#endif
|
||||
m_ses.m_half_open.enqueue(
|
||||
boost::bind(&peer_connection::on_connect, c, _1)
|
||||
, boost::bind(&peer_connection::on_timeout, c)
|
||||
, seconds(timeout));
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception&)
|
||||
TORRENT_CATCH (std::exception&)
|
||||
{
|
||||
std::set<peer_connection*>::iterator i
|
||||
= m_connections.find(boost::get_pointer(c));
|
||||
|
@ -4837,7 +4819,6 @@ namespace libtorrent
|
|||
c->disconnect(errors::no_error, 1);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_share_mode)
|
||||
recalc_share_mode();
|
||||
|
@ -4937,10 +4918,8 @@ namespace libtorrent
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
TORRENT_TRY
|
||||
{
|
||||
#endif
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
|
@ -4951,9 +4930,8 @@ namespace libtorrent
|
|||
#endif
|
||||
if (!m_policy.new_connection(*p, m_ses.session_time()))
|
||||
return false;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception& e)
|
||||
TORRENT_CATCH (std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
#if defined TORRENT_LOGGING
|
||||
|
@ -4963,7 +4941,6 @@ namespace libtorrent
|
|||
p->disconnect(errors::no_error);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
TORRENT_ASSERT(m_connections.find(p) == m_connections.end());
|
||||
peer_iterator ci = m_connections.insert(p).first;
|
||||
#ifdef TORRENT_DEBUG
|
||||
|
@ -5291,13 +5268,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->on_files_checked();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6000,13 +5973,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
if ((*i)->on_pause()) return;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6149,13 +6118,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
if ((*i)->on_resume()) return;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6292,13 +6257,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->tick();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6438,14 +6399,10 @@ namespace libtorrent
|
|||
|
||||
// updates the peer connection's ul/dl bandwidth
|
||||
// resource requests
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
p->second_tick(tick_interval_ms);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception& e)
|
||||
TORRENT_CATCH (std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
|
@ -6453,7 +6410,6 @@ namespace libtorrent
|
|||
#endif
|
||||
p->disconnect(errors::no_error, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (m_ses.m_alerts.should_post<stats_alert>())
|
||||
m_ses.m_alerts.post_alert(stats_alert(get_handle(), tick_interval_ms, m_stat));
|
||||
|
@ -7143,13 +7099,9 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
(*i)->on_state(m_state);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -273,9 +273,7 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_
|
|||
|
||||
if (e)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
if (s == &m_ipv6_sock)
|
||||
|
@ -284,9 +282,7 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_
|
|||
#endif
|
||||
m_callback(e, m_v4_ep, 0, 0);
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
|
||||
// don't stop listening on recoverable errors
|
||||
if (e != asio::error::host_unreachable
|
||||
|
@ -340,9 +336,7 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_
|
|||
#if TORRENT_USE_IPV6
|
||||
if (s == &m_ipv6_sock)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
|
||||
if (m_tunnel_packets)
|
||||
{
|
||||
|
@ -355,9 +349,7 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_
|
|||
m_callback(e, m_v6_ep, m_v6_buf, bytes_transferred);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
|
@ -378,9 +370,7 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_
|
|||
#endif // TORRENT_USE_IPV6
|
||||
{
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
|
||||
if (m_tunnel_packets)
|
||||
{
|
||||
|
@ -393,9 +383,7 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_
|
|||
m_callback(e, m_v4_ep, m_v4_buf, bytes_transferred);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
|
@ -732,13 +720,9 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
|
|||
|
||||
if (e)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
if (m_callback) m_callback(e, udp::endpoint(), 0, 0);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -792,13 +776,9 @@ void udp_socket::on_connected(error_code const& e)
|
|||
m_connection_ticket = -1;
|
||||
if (e)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
TORRENT_TRY {
|
||||
if (m_callback) m_callback(e, udp::endpoint(), 0, 0);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(std::exception&) {}
|
||||
#endif
|
||||
} TORRENT_CATCH (std::exception&) {}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
16
src/upnp.cpp
16
src/upnp.cpp
|
@ -286,10 +286,8 @@ void upnp::resend_request(error_code const& ec)
|
|||
// ask for it
|
||||
rootdevice& d = const_cast<rootdevice&>(*i);
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
TORRENT_TRY
|
||||
{
|
||||
#endif
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "connecting to: %s", d.url.c_str());
|
||||
log(msg, l);
|
||||
|
@ -298,16 +296,14 @@ void upnp::resend_request(error_code const& ec)
|
|||
, m_cc, boost::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& exc)
|
||||
TORRENT_CATCH (std::exception& exc)
|
||||
{
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "connection failed to: %s %s", d.url.c_str(), exc.what());
|
||||
log(msg, l);
|
||||
d.disabled = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -546,10 +542,8 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
|||
// ask for it
|
||||
rootdevice& d = const_cast<rootdevice&>(*i);
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
TORRENT_TRY
|
||||
{
|
||||
#endif
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "connecting to: %s"
|
||||
, d.url.c_str());
|
||||
|
@ -560,9 +554,8 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
|||
, m_cc, boost::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& exc)
|
||||
TORRENT_CATCH (std::exception& exc)
|
||||
{
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "connection failed to: %s %s"
|
||||
|
@ -570,7 +563,6 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
|||
log(msg, l);
|
||||
d.disabled = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue