diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 1bfc9047e..3c1706817 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -526,6 +526,10 @@ namespace libtorrent // attempted to connect yet (i.e. it's queued for // connection attempt). bool is_queued() const { return m_queued; } + + // returns true if this peer has successfully completed its connection + // attempt to the remote end. + bool is_connected() const { return m_connected; } // called when it's time for this peer_conncetion to actually // initiate the tcp connection. This may be postponed until diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 940d1b03c..d3c95a9f1 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4612,7 +4612,7 @@ namespace libtorrent { for (int channel = 0; channel < 2; ++channel) { - if ((warning & (1 << channel)) == 0) return; + if ((warning & (1 << channel)) == 0) continue; t->alerts().post_alert(performance_alert(t->get_handle() , channel == peer_connection::download_channel ? performance_alert::download_limit_too_low @@ -5547,6 +5547,8 @@ namespace libtorrent size_t peer_connection::try_read(sync_t s, error_code& ec) { + TORRENT_ASSERT(m_connected); + if (m_quota[download_channel] == 0) { ec = asio::error::would_block;