lt sync 1746

This commit is contained in:
Marcos Pinto 2007-11-19 14:14:22 +00:00
parent 1ae6dbf871
commit 9afc4ce936
6 changed files with 27 additions and 4 deletions

View File

@ -123,6 +123,7 @@ public:
{ {
m_remote_endpoint = endpoint_type(); m_remote_endpoint = endpoint_type();
m_sock.close(); m_sock.close();
m_resolver.cancel();
} }
void close(asio::error_code& ec) void close(asio::error_code& ec)

View File

@ -115,6 +115,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
, use_dht_as_fallback(true) , use_dht_as_fallback(true)
#endif #endif
, free_torrent_hashes(true)
{} {}
// this is the user agent that will be sent to the tracker // this is the user agent that will be sent to the tracker
@ -281,6 +282,12 @@ namespace libtorrent
// tracker is online // tracker is online
bool use_dht_as_fallback; bool use_dht_as_fallback;
#endif #endif
// if this is true, the piece hashes will be freed, in order
// to save memory, once the torrent is seeding. This will
// make the get_torrent_info() function to return an incomplete
// torrent object that cannot be passed back to add_torrent()
bool free_torrent_hashes;
}; };
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT

View File

@ -1272,7 +1272,13 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield); // Don't require the bitfield to have been sent at this point
// the case where m_sent_bitfield may not be true is if the
// torrent doesn't have any metadata, and a peer is timimg out.
// then the keep-alive message will be sent before the bitfield
// this is a violation to the original protocol, but necessary
// for the metadata extension.
TORRENT_ASSERT(m_sent_handshake);
char msg[] = {0,0,0,0}; char msg[] = {0,0,0,0};
send_buffer(msg, sizeof(msg)); send_buffer(msg, sizeof(msg));
@ -2477,6 +2483,11 @@ namespace libtorrent
TORRENT_ASSERT(!m_rc4_encrypted || m_RC4_handler.get()); TORRENT_ASSERT(!m_rc4_encrypted || m_RC4_handler.get());
#endif #endif
if (!in_handshake())
{
TORRENT_ASSERT(m_sent_handshake);
}
if (!m_in_constructor) if (!m_in_constructor)
peer_connection::check_invariant(); peer_connection::check_invariant();

View File

@ -87,7 +87,7 @@ int distance_exp(node_id const& n1, node_id const& n2)
// return the bit-number of the first bit // return the bit-number of the first bit
// that differs // that differs
int bit = byte * 8; int bit = byte * 8;
for (int b = 7; b > 0; --b) for (int b = 7; b >= 0; --b)
if (t >= (1 << b)) return bit + b; if (t >= (1 << b)) return bit + b;
return bit; return bit;
} }

View File

@ -2317,6 +2317,8 @@ namespace detail
void session_impl::stop_lsd() void session_impl::stop_lsd()
{ {
mutex_t::scoped_lock l(m_mutex); mutex_t::scoped_lock l(m_mutex);
if (m_lsd.get())
m_lsd->close();
m_lsd = 0; m_lsd = 0;
} }

View File

@ -1153,7 +1153,8 @@ namespace libtorrent
if (is_seed()) if (is_seed())
{ {
m_picker.reset(); m_picker.reset();
m_torrent_file->seed_free(); if (m_ses.settings().free_torrent_hashes)
m_torrent_file->seed_free();
} }
} }
@ -2347,7 +2348,8 @@ namespace libtorrent
if (is_seed()) if (is_seed())
{ {
m_picker.reset(); m_picker.reset();
m_torrent_file->seed_free(); if (m_ses.settings().free_torrent_hashes)
m_torrent_file->seed_free();
} }
if (!m_connections_initialized) if (!m_connections_initialized)