fix no-metadata case to not send any other messages before the bitfield (which is sent once we have the metadata)

This commit is contained in:
Arvid Norberg 2008-08-16 22:07:15 +00:00
parent 5b28964c22
commit 89907cdae8
2 changed files with 8 additions and 0 deletions

View File

@ -252,6 +252,7 @@ namespace libtorrent
if (m_supports_dht_port && m_ses.m_dht) if (m_supports_dht_port && m_ses.m_dht)
write_dht_port(m_ses.get_dht_settings().service_port); write_dht_port(m_ses.get_dht_settings().service_port);
#endif #endif
if (is_interesting()) write_interested();
} }
void bt_peer_connection::write_dht_port(int listen_port) void bt_peer_connection::write_dht_port(int listen_port)
@ -1435,6 +1436,9 @@ namespace libtorrent
else if (t->num_have() == 0) else if (t->num_have() == 0)
{ {
// don't send a bitfield if we don't have any pieces // don't send a bitfield if we don't have any pieces
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " *** NOT SENDING BITFIELD";
#endif
#ifndef NDEBUG #ifndef NDEBUG
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif

View File

@ -2133,6 +2133,8 @@ namespace libtorrent
{ {
if (m_interesting) return; if (m_interesting) return;
m_interesting = true; m_interesting = true;
boost::shared_ptr<torrent> t = m_torrent.lock();
if (!t->valid_metadata()) return;
write_interested(); write_interested();
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
@ -2144,6 +2146,8 @@ namespace libtorrent
{ {
if (!m_interesting) return; if (!m_interesting) return;
m_interesting = false; m_interesting = false;
boost::shared_ptr<torrent> t = m_torrent.lock();
if (!t->valid_metadata()) return;
write_not_interested(); write_not_interested();
m_became_uninteresting = time_now(); m_became_uninteresting = time_now();