removed dependencies on exceptions from policy

This commit is contained in:
Arvid Norberg 2008-04-07 01:29:21 +00:00
parent 9fe5bb7a7d
commit 2fe729c9f5
2 changed files with 82 additions and 105 deletions

View File

@ -94,7 +94,7 @@ namespace libtorrent
bool new_connection(peer_connection& c);
// the given connection was just closed
void connection_closed(const peer_connection& c) throw();
void connection_closed(const peer_connection& c);
// the peer has got at least one interesting piece
void peer_is_interesting(peer_connection& c);

View File

@ -873,8 +873,6 @@ namespace libtorrent
return 0;
}
try
{
iterator i;
if (m_torrent->settings().allow_multiple_connections_per_ip)
@ -921,9 +919,13 @@ namespace libtorrent
#endif
i->second.inet_as = ses.lookup_as(as);
#endif
if (is_connect_candidate(i->second, m_torrent->is_finished()))
++m_num_connect_candidates;
}
else
{
bool was_conn_cand = is_connect_candidate(i->second, m_torrent->is_finished());
i->second.type = peer::connectable;
i->second.ip = remote;
@ -959,23 +961,14 @@ namespace libtorrent
TORRENT_ASSERT(i->second.connection->associated_torrent().lock().get() == m_torrent);
}
#endif
}
if (is_connect_candidate(i->second, m_torrent->is_finished()))
++m_num_connect_candidates;
if (was_conn_cand != is_connect_candidate(i->second, m_torrent->is_finished()))
if (was_conn_cand) --m_num_connect_candidates;
else ++m_num_connect_candidates;
}
return &i->second;
}
catch(std::exception& e)
{
if (m_torrent->alerts().should_post(alert::debug))
{
m_torrent->alerts().post_alert(
peer_error_alert(remote, pid, e.what()));
}
}
return 0;
}
// this is called when we are choked by a peer
// i.e. a peer lets us know that we will not receive
@ -1146,29 +1139,13 @@ namespace libtorrent
TORRENT_ASSERT(!p->second.connection);
TORRENT_ASSERT(p->second.type == peer::connectable);
try
{
if (!m_torrent->connect_to_peer(&p->second))
{
++p->second.failcount;
return false;
}
p->second.connection->add_stat(p->second.prev_amount_download, p->second.prev_amount_upload);
p->second.prev_amount_download = 0;
p->second.prev_amount_upload = 0;
return true;
}
catch (std::exception& e)
{
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_torrent->session().m_logger) << "*** CONNECTION FAILED '"
<< e.what() << "'\n";
#endif
std::cerr << e.what() << std::endl;
++p->second.failcount;
return false;
}
}
bool policy::disconnect_one_peer()
{
@ -1184,7 +1161,7 @@ namespace libtorrent
}
// this is called whenever a peer connection is closed
void policy::connection_closed(const peer_connection& c) throw()
void policy::connection_closed(const peer_connection& c)
{
// too expensive
// INVARIANT_CHECK;
@ -1251,8 +1228,8 @@ namespace libtorrent
// INVARIANT_CHECK;
TORRENT_ASSERT(c);
try { TORRENT_ASSERT(c->remote() == c->get_socket()->remote_endpoint()); }
catch (std::exception&) {}
asio::error_code ec;
TORRENT_ASSERT(c->remote() == c->get_socket()->remote_endpoint(ec) || ec);
return std::find_if(
m_peers.begin()