previous checkin was a mistake

This commit is contained in:
Arvid Norberg 2008-03-25 04:44:30 +00:00
parent b6be33b5b6
commit 5860ca8706
3 changed files with 14 additions and 47 deletions

View File

@ -2212,7 +2212,6 @@ namespace libtorrent
{ {
TORRENT_ASSERT(m_storage_mode == storage_mode_compact); TORRENT_ASSERT(m_storage_mode == storage_mode_compact);
TORRENT_ASSERT(m_unallocated_slots.empty()); TORRENT_ASSERT(m_unallocated_slots.empty());
TORRENT_ASSERT(m_free_slots.empty());
// we have allocated all slots, switch to // we have allocated all slots, switch to
// full allocation mode in order to free // full allocation mode in order to free
// some unnecessary memory. // some unnecessary memory.
@ -2331,8 +2330,10 @@ namespace libtorrent
TORRENT_ASSERT(slot_index >= 0); TORRENT_ASSERT(slot_index >= 0);
TORRENT_ASSERT(slot_index < (int)m_slot_to_piece.size()); TORRENT_ASSERT(slot_index < (int)m_slot_to_piece.size());
if (m_free_slots.empty() && m_unallocated_slots.empty()) if (m_unallocated_slots.empty())
{
switch_to_full_mode(); switch_to_full_mode();
}
return slot_index; return slot_index;
} }
@ -2399,9 +2400,7 @@ namespace libtorrent
TORRENT_ASSERT(m_current_slot <= m_info->num_pieces()); TORRENT_ASSERT(m_current_slot <= m_info->num_pieces());
if (m_unallocated_slots.empty() if (m_unallocated_slots.empty() && m_state == state_finished)
&& m_free_slots.empty()
&& m_state == state_finished)
{ {
TORRENT_ASSERT(m_storage_mode != storage_mode_compact); TORRENT_ASSERT(m_storage_mode != storage_mode_compact);
} }

View File

@ -39,37 +39,7 @@ void udp_socket::send(udp::endpoint const& ep, char const* p, int len, asio::err
void udp_socket::on_read(udp::socket* s, asio::error_code const& e, std::size_t bytes_transferred) void udp_socket::on_read(udp::socket* s, asio::error_code const& e, std::size_t bytes_transferred)
{ {
if (e) if (e) return;
{
#ifndef BOOST_NO_EXCEPTIONS
try {
#endif
if (s == &m_ipv4_sock)
m_callback(e, m_v4_ep, 0, 0);
else
m_callback(e, m_v6_ep, 0, 0);
#ifndef BOOST_NO_EXCEPTIONS
} catch(std::exception&) {}
#endif
// don't stop listening on recoverable errors
if (e != asio::error::host_unreachable
&& e != asio::error::fault
&& e != asio::error::connection_reset
&& e != asio::error::connection_refused
&& e != asio::error::connection_aborted
&& e != asio::error::message_size)
return;
if (s == &m_ipv4_sock)
s->async_receive_from(asio::buffer(m_v4_buf, sizeof(m_v4_buf))
, m_v4_ep, boost::bind(&udp_socket::on_read, this, s, _1, _2));
else
s->async_receive_from(asio::buffer(m_v6_buf, sizeof(m_v6_buf))
, m_v6_ep, boost::bind(&udp_socket::on_read, this, s, _1, _2));
return;
}
if (!m_callback) return; if (!m_callback) return;
if (s == &m_ipv4_sock) if (s == &m_ipv4_sock)
@ -79,9 +49,9 @@ void udp_socket::on_read(udp::socket* s, asio::error_code const& e, std::size_t
#endif #endif
if (m_tunnel_packets && m_v4_ep == m_proxy_addr) if (m_tunnel_packets && m_v4_ep == m_proxy_addr)
unwrap(e, m_v4_buf, bytes_transferred); unwrap(m_v4_buf, bytes_transferred);
else else
m_callback(e, m_v4_ep, m_v4_buf, bytes_transferred); m_callback(m_v4_ep, m_v4_buf, bytes_transferred);
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
} catch(std::exception&) {} } catch(std::exception&) {}
@ -96,9 +66,9 @@ void udp_socket::on_read(udp::socket* s, asio::error_code const& e, std::size_t
#endif #endif
if (m_tunnel_packets && m_v6_ep == m_proxy_addr) if (m_tunnel_packets && m_v6_ep == m_proxy_addr)
unwrap(e, m_v6_buf, bytes_transferred); unwrap(m_v6_buf, bytes_transferred);
else else
m_callback(e, m_v6_ep, m_v6_buf, bytes_transferred); m_callback(m_v6_ep, m_v6_buf, bytes_transferred);
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
} catch(std::exception&) {} } catch(std::exception&) {}
@ -132,7 +102,7 @@ void udp_socket::wrap(udp::endpoint const& ep, char const* p, int len, asio::err
} }
// unwrap the UDP packet from the SOCKS5 header // unwrap the UDP packet from the SOCKS5 header
void udp_socket::unwrap(asio::error_code const& e, char const* buf, int size) void udp_socket::unwrap(char const* buf, int size)
{ {
using namespace libtorrent::detail; using namespace libtorrent::detail;
@ -158,6 +128,7 @@ void udp_socket::unwrap(asio::error_code const& e, char const* buf, int size)
{ {
// IPv6 // IPv6
TORRENT_ASSERT(false && "not supported yet"); TORRENT_ASSERT(false && "not supported yet");
} }
else else
{ {
@ -165,7 +136,7 @@ void udp_socket::unwrap(asio::error_code const& e, char const* buf, int size)
return; return;
} }
m_callback(e, sender, p, size - (p - buf)); m_callback(sender, p, size - (p - buf));
} }
void udp_socket::close() void udp_socket::close()

View File

@ -84,7 +84,7 @@ namespace libtorrent
: tracker_connection(man, req, ios, bind_infc, c) : tracker_connection(man, req, ios, bind_infc, c)
, m_man(man) , m_man(man)
, m_name_lookup(ios) , m_name_lookup(ios)
, m_socket(ios, boost::bind(&udp_tracker_connection::on_receive, this, _1, _2, _3, _4), cc) , m_socket(ios, boost::bind(&udp_tracker_connection::on_receive, this, _1, _2, _3), cc)
, m_transaction_id(0) , m_transaction_id(0)
, m_connection_id(0) , m_connection_id(0)
, m_settings(stn) , m_settings(stn)
@ -185,8 +185,7 @@ namespace libtorrent
tracker_connection::close(); tracker_connection::close();
} }
void udp_tracker_connection::on_receive(asio::error_code const& e void udp_tracker_connection::on_receive(udp::endpoint const& ep, char const* buf, int size)
, udp::endpoint const& ep, char const* buf, int size)
{ {
// ignore resposes before we've sent any requests // ignore resposes before we've sent any requests
if (m_state == action_error) return; if (m_state == action_error) return;
@ -195,8 +194,6 @@ namespace libtorrent
// ignore packet not sent from the tracker // ignore packet not sent from the tracker
if (m_target != ep) return; if (m_target != ep) return;
if (e) fail(-1, e.message().c_str());
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();