added catch blocks to lsd. changed bind expressions to use operators
This commit is contained in:
parent
9f1a11aa50
commit
f41fd7d303
|
@ -244,8 +244,7 @@ int peer_index(libtorrent::tcp::endpoint addr, std::vector<libtorrent::peer_info
|
|||
{
|
||||
using namespace libtorrent;
|
||||
std::vector<peer_info>::const_iterator i = std::find_if(peers.begin()
|
||||
, peers.end(), boost::bind(std::equal_to<libtorrent::tcp::endpoint>()
|
||||
, bind(&peer_info::ip, _1), addr));
|
||||
, peers.end(), bind(&peer_info::ip, _1) == addr);
|
||||
if (i == peers.end()) return -1;
|
||||
|
||||
return i - peers.begin();
|
||||
|
|
|
@ -170,11 +170,11 @@ bool routing_table::need_node(node_id const& id)
|
|||
if ((int)rb.size() >= m_bucket_size) return false;
|
||||
|
||||
// if the node already exists, we don't need it
|
||||
if (std::find_if(b.begin(), b.end(), bind(std::equal_to<node_id>()
|
||||
, bind(&node_entry::id, _1), id)) != b.end()) return false;
|
||||
if (std::find_if(b.begin(), b.end(), bind(&node_entry::id, _1) == id)
|
||||
!= b.end()) return false;
|
||||
|
||||
if (std::find_if(rb.begin(), rb.end(), bind(std::equal_to<node_id>()
|
||||
, bind(&node_entry::id, _1), id)) != rb.end()) return false;
|
||||
if (std::find_if(rb.begin(), rb.end(), bind(&node_entry::id, _1) == id)
|
||||
!= rb.end()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -188,8 +188,7 @@ void routing_table::node_failed(node_id const& id)
|
|||
bucket_t& rb = m_buckets[bucket_index].second;
|
||||
|
||||
bucket_t::iterator i = std::find_if(b.begin(), b.end()
|
||||
, bind(std::equal_to<node_id>()
|
||||
, bind(&node_entry::id, _1), id));
|
||||
, bind(&node_entry::id, _1) == id);
|
||||
|
||||
if (i == b.end()) return;
|
||||
|
||||
|
@ -238,8 +237,7 @@ bool routing_table::node_seen(node_id const& id, udp::endpoint addr)
|
|||
bucket_t& b = m_buckets[bucket_index].first;
|
||||
|
||||
bucket_t::iterator i = std::find_if(b.begin(), b.end()
|
||||
, bind(std::equal_to<node_id>()
|
||||
, bind(&node_entry::id, _1), id));
|
||||
, bind(&node_entry::id, _1) == id);
|
||||
|
||||
bool ret = need_bootstrap();
|
||||
|
||||
|
@ -286,9 +284,8 @@ bool routing_table::node_seen(node_id const& id, udp::endpoint addr)
|
|||
// with nodes from that cache.
|
||||
|
||||
i = std::max_element(b.begin(), b.end()
|
||||
, bind(std::less<int>()
|
||||
, bind(&node_entry::fail_count, _1)
|
||||
, bind(&node_entry::fail_count, _2)));
|
||||
, bind(&node_entry::fail_count, _1)
|
||||
< bind(&node_entry::fail_count, _2));
|
||||
|
||||
if (i != b.end() && i->fail_count > 0)
|
||||
{
|
||||
|
@ -308,8 +305,7 @@ bool routing_table::node_seen(node_id const& id, udp::endpoint addr)
|
|||
bucket_t& rb = m_buckets[bucket_index].second;
|
||||
|
||||
i = std::find_if(rb.begin(), rb.end()
|
||||
, bind(std::equal_to<node_id>()
|
||||
, bind(&node_entry::id, _1), id));
|
||||
, bind(&node_entry::id, _1) == id);
|
||||
|
||||
// if the node is already in the replacement bucket
|
||||
// just return.
|
||||
|
@ -351,8 +347,7 @@ void routing_table::find_node(node_id const& target
|
|||
if ((int)l.size() == count)
|
||||
{
|
||||
assert(std::count_if(l.begin(), l.end()
|
||||
, boost::bind(std::not_equal_to<int>()
|
||||
, boost::bind(&node_entry::fail_count, _1), 0)) == 0);
|
||||
, boost::bind(&node_entry::fail_count, _1) != 0) == 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -384,8 +379,7 @@ void routing_table::find_node(node_id const& target
|
|||
|| bucket_index == (int)m_buckets.size() - 1)
|
||||
{
|
||||
assert(std::count_if(l.begin(), l.end()
|
||||
, boost::bind(std::not_equal_to<int>()
|
||||
, boost::bind(&node_entry::fail_count, _1), 0)) == 0);
|
||||
, boost::bind(&node_entry::fail_count, _1) != 0) == 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -399,8 +393,7 @@ void routing_table::find_node(node_id const& target
|
|||
{
|
||||
l.erase(l.begin() + count, l.end());
|
||||
assert(std::count_if(l.begin(), l.end()
|
||||
, boost::bind(std::not_equal_to<int>()
|
||||
, boost::bind(&node_entry::fail_count, _1), 0)) == 0);
|
||||
, boost::bind(&node_entry::fail_count, _1) != 0) == 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -409,8 +402,7 @@ void routing_table::find_node(node_id const& target
|
|||
assert((int)l.size() <= count);
|
||||
|
||||
assert(std::count_if(l.begin(), l.end()
|
||||
, boost::bind(std::not_equal_to<int>()
|
||||
, boost::bind(&node_entry::fail_count, _1), 0)) == 0);
|
||||
, boost::bind(&node_entry::fail_count, _1) != 0) == 0);
|
||||
}
|
||||
|
||||
routing_table::iterator routing_table::begin() const
|
||||
|
|
|
@ -68,8 +68,7 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig
|
|||
if (i == m_results.end() || i->id != id)
|
||||
{
|
||||
assert(std::find_if(m_results.begin(), m_results.end()
|
||||
, bind(std::equal_to<node_id>()
|
||||
, bind(&result::id, _1), id)) == m_results.end());
|
||||
, bind(&result::id, _1) == id) == m_results.end());
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(traversal) << "adding result: " << id << " " << addr;
|
||||
#endif
|
||||
|
|
|
@ -163,7 +163,7 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
|
|||
m_broadcast_timer.async_wait(bind(&lsd::resend_announce, this, _1, msg));
|
||||
}
|
||||
|
||||
void lsd::resend_announce(asio::error_code const& e, std::string msg)
|
||||
void lsd::resend_announce(asio::error_code const& e, std::string msg) try
|
||||
{
|
||||
if (e) return;
|
||||
|
||||
|
@ -177,6 +177,8 @@ void lsd::resend_announce(asio::error_code const& e, std::string msg)
|
|||
m_broadcast_timer.expires_from_now(milliseconds(250 * m_retry_count));
|
||||
m_broadcast_timer.async_wait(bind(&lsd::resend_announce, this, _1, msg));
|
||||
}
|
||||
catch (std::exception&)
|
||||
{}
|
||||
|
||||
void lsd::on_announce(asio::error_code const& e
|
||||
, std::size_t bytes_transferred)
|
||||
|
@ -235,7 +237,7 @@ void lsd::on_announce(asio::error_code const& e
|
|||
setup_receive();
|
||||
}
|
||||
|
||||
void lsd::setup_receive()
|
||||
void lsd::setup_receive() try
|
||||
{
|
||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
||||
m_log << time_now_string()
|
||||
|
@ -245,6 +247,8 @@ void lsd::setup_receive()
|
|||
m_socket.async_receive_from(asio::buffer(m_receive_buffer
|
||||
, sizeof(m_receive_buffer)), m_remote, bind(&lsd::on_announce, this, _1, _2));
|
||||
}
|
||||
catch (std::exception&)
|
||||
{}
|
||||
|
||||
void lsd::close()
|
||||
{
|
||||
|
|
|
@ -435,6 +435,9 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
void torrent::on_announce()
|
||||
#ifndef NDEBUG
|
||||
try
|
||||
#endif
|
||||
{
|
||||
boost::weak_ptr<torrent> self(shared_from_this());
|
||||
|
||||
|
@ -458,6 +461,13 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
||||
|
|
Loading…
Reference in New Issue