slight refactoring to remove a dependency on session_impl in rpc_manager

This commit is contained in:
Arvid Norberg 2013-02-05 04:18:44 +00:00
parent 28780c2a9f
commit f73fa778d6
5 changed files with 15 additions and 9 deletions

View File

@ -511,6 +511,9 @@ namespace libtorrent
// implements dht_observer
virtual void set_external_address(address const& ip
, address const& source);
void set_external_address(address const& ip
, int source_type, address const& source);
external_ip const& external_address() const;

View File

@ -40,7 +40,7 @@ namespace libtorrent { namespace dht
struct dht_observer
{
virtual void set_external_address(address const& addr
, int source_type, address const& source) = 0;
, address const& source) = 0;
};
}}

View File

@ -33,10 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/pch.hpp"
#include "libtorrent/socket.hpp"
// TODO: 3 remove this dependency by having the dht observer
// have its own flags
#include "libtorrent/aux_/session_impl.hpp"
#include <boost/bind.hpp>
#include <libtorrent/io.hpp>
@ -349,7 +345,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id)
memcpy(&b[0], ext_ip->string_ptr(), 4);
if (m_observer)
m_observer->set_external_address(address_v4(b)
, aux::session_impl::source_dht, m.addr.address());
, m.addr.address());
}
#if TORRENT_USE_IPV6
else if (ext_ip && ext_ip->string_length() == 16)
@ -359,7 +355,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id)
memcpy(&b[0], ext_ip->string_ptr(), 16);
if (m_observer)
m_observer->set_external_address(address_v6(b)
, aux::session_impl::source_dht, m.addr.address());
, m.addr.address());
}
#endif

View File

@ -6115,6 +6115,13 @@ retry:
external_ip const& session_impl::external_address() const
{ return m_external_ip; }
// this is the DHT observer version. DHT is the implied source
void session_impl::set_external_address(address const& ip
, address const& source)
{
set_external_address(ip, source_dht, source);
}
void session_impl::set_external_address(address const& ip
, int source_type, address const& source)
{

View File

@ -409,10 +409,10 @@ struct utp_socket_impl
// timers when we should trigger the read and
// write callbacks (unless the buffers fill up
// before)
// TODO: 3 remove the read timeout concept. This should not be necessary
// TODO: 3 remove the read timeout concept. This should not be necessary, use nagle-like semantics instead
ptime m_read_timeout;
// TODO: 3 remove the write timeout concept. This should not be necessary
// TODO: 3 remove the write timeout concept. This should not be necessary, use nagle-like semantics instead
ptime m_write_timeout;
// the time when the last packet we sent times out. Including re-sends.