peer_connection fix for incoming connections
This commit is contained in:
parent
756dbe3316
commit
f259e34f86
|
@ -100,6 +100,7 @@ namespace libtorrent
|
|||
bt_peer_connection(
|
||||
aux::session_impl& ses
|
||||
, boost::shared_ptr<socket_type> s
|
||||
, tcp::endpoint const& remote
|
||||
, policy::peer* peerinfo);
|
||||
|
||||
void start();
|
||||
|
|
|
@ -121,6 +121,7 @@ namespace libtorrent
|
|||
peer_connection(
|
||||
aux::session_impl& ses
|
||||
, boost::shared_ptr<socket_type> s
|
||||
, tcp::endpoint const& remote
|
||||
, policy::peer* peerinfo);
|
||||
|
||||
// this function is called after it has been constructed and properly
|
||||
|
|
|
@ -125,8 +125,9 @@ namespace libtorrent
|
|||
bt_peer_connection::bt_peer_connection(
|
||||
session_impl& ses
|
||||
, boost::shared_ptr<socket_type> s
|
||||
, tcp::endpoint const& remote
|
||||
, policy::peer* peerinfo)
|
||||
: peer_connection(ses, s, peerinfo)
|
||||
: peer_connection(ses, s, remote, peerinfo)
|
||||
, m_state(read_protocol_identifier)
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
, m_supports_extensions(false)
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace libtorrent
|
|||
session_impl& ses
|
||||
, boost::weak_ptr<torrent> tor
|
||||
, shared_ptr<socket_type> s
|
||||
, tcp::endpoint const& remote
|
||||
, tcp::endpoint const& endp
|
||||
, policy::peer* peerinfo)
|
||||
:
|
||||
#ifndef NDEBUG
|
||||
|
@ -86,7 +86,7 @@ namespace libtorrent
|
|||
, m_last_receive(time_now())
|
||||
, m_last_sent(time_now())
|
||||
, m_socket(s)
|
||||
, m_remote(remote)
|
||||
, m_remote(endp)
|
||||
, m_torrent(tor)
|
||||
, m_active(true)
|
||||
, m_peer_interested(false)
|
||||
|
@ -164,6 +164,7 @@ namespace libtorrent
|
|||
peer_connection::peer_connection(
|
||||
session_impl& ses
|
||||
, boost::shared_ptr<socket_type> s
|
||||
, tcp::endpoint const& endp
|
||||
, policy::peer* peerinfo)
|
||||
:
|
||||
#ifndef NDEBUG
|
||||
|
@ -185,6 +186,7 @@ namespace libtorrent
|
|||
, m_last_receive(time_now())
|
||||
, m_last_sent(time_now())
|
||||
, m_socket(s)
|
||||
, m_remote(endp)
|
||||
, m_active(false)
|
||||
, m_peer_interested(false)
|
||||
, m_peer_choked(true)
|
||||
|
@ -244,7 +246,7 @@ namespace libtorrent
|
|||
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
error_code ec;
|
||||
TORRENT_ASSERT(m_socket->remote_endpoint(ec) == remote() || ec);
|
||||
TORRENT_ASSERT(m_socket->remote_endpoint(ec) == m_remote || ec);
|
||||
m_logger = m_ses.create_log(remote().address().to_string(ec) + "_"
|
||||
+ boost::lexical_cast<std::string>(remote().port()), m_ses.listen_port());
|
||||
(*m_logger) << "*** INCOMING CONNECTION\n";
|
||||
|
|
|
@ -847,7 +847,13 @@ namespace aux {
|
|||
|
||||
// check if we have any active torrents
|
||||
// if we don't reject the connection
|
||||
if (m_torrents.empty()) return;
|
||||
if (m_torrents.empty())
|
||||
{
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << " There are no torrents, disconnect\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
bool has_active_torrent = false;
|
||||
for (torrent_map::iterator i = m_torrents.begin()
|
||||
|
@ -859,10 +865,16 @@ namespace aux {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!has_active_torrent) return;
|
||||
if (!has_active_torrent)
|
||||
{
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << " There are no _active_ torrents, disconnect\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
boost::intrusive_ptr<peer_connection> c(
|
||||
new bt_peer_connection(*this, s, 0));
|
||||
new bt_peer_connection(*this, s, endp, 0));
|
||||
#ifndef NDEBUG
|
||||
c->m_in_constructor = false;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue