diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 891392bb4..2fb491ac3 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -244,8 +244,7 @@ int peer_index(libtorrent::tcp::endpoint addr, std::vector::const_iterator i = std::find_if(peers.begin() - , peers.end(), boost::bind(std::equal_to() - , bind(&peer_info::ip, _1), addr)); + , peers.end(), bind(&peer_info::ip, _1) == addr); if (i == peers.end()) return -1; return i - peers.begin(); diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 77c7dd826..cfb42af5e 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -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() - , 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() - , 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() - , 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() - , 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() - , 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() - , 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() - , 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() - , 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() - , 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() - , 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 diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index 3dcfcaecf..e149281fe 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -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() - , 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 diff --git a/src/lsd.cpp b/src/lsd.cpp index 5fee68d58..f3ca72403 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -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() { diff --git a/src/torrent.cpp b/src/torrent.cpp index 1db508d22..fe6497dc1 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -435,6 +435,9 @@ namespace libtorrent } void torrent::on_announce() +#ifndef NDEBUG + try +#endif { boost::weak_ptr 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