From 89907cdae864322d8d4790dbb0951e8ec18c26bb Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 16 Aug 2008 22:07:15 +0000 Subject: [PATCH] fix no-metadata case to not send any other messages before the bitfield (which is sent once we have the metadata) --- src/bt_peer_connection.cpp | 4 ++++ src/peer_connection.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 1d7b5830f..c68640d79 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -252,6 +252,7 @@ namespace libtorrent if (m_supports_dht_port && m_ses.m_dht) write_dht_port(m_ses.get_dht_settings().service_port); #endif + if (is_interesting()) write_interested(); } void bt_peer_connection::write_dht_port(int listen_port) @@ -1435,6 +1436,9 @@ namespace libtorrent else if (t->num_have() == 0) { // 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 m_sent_bitfield = true; #endif diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 95dda99f9..e8451d036 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2133,6 +2133,8 @@ namespace libtorrent { if (m_interesting) return; m_interesting = true; + boost::shared_ptr t = m_torrent.lock(); + if (!t->valid_metadata()) return; write_interested(); #ifdef TORRENT_VERBOSE_LOGGING @@ -2144,6 +2146,8 @@ namespace libtorrent { if (!m_interesting) return; m_interesting = false; + boost::shared_ptr t = m_torrent.lock(); + if (!t->valid_metadata()) return; write_not_interested(); m_became_uninteresting = time_now();