Browse Source

Fixed creation of shared_ptr in RLPXSocket.

cl-refactor
chriseth 10 years ago
parent
commit
db0bcb9f8c
  1. 4
      libp2p/Host.cpp
  2. 3
      libp2p/RLPXSocket.h

4
libp2p/Host.cpp

@ -396,7 +396,7 @@ void Host::runAcceptor()
clog(NetConnect) << "Listening on local port " << m_listenPort << " (public: " << m_tcpPublic << ")";
m_accepting = true;
auto socket = make_shared<RLPXSocket>(new bi::tcp::socket(m_ioService));
auto socket = make_shared<RLPXSocket>(m_ioService);
m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec)
{
m_accepting = false;
@ -552,7 +552,7 @@ void Host::connect(std::shared_ptr<Peer> const& _p)
bi::tcp::endpoint ep(_p->endpoint);
clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id();
auto socket = make_shared<RLPXSocket>(new bi::tcp::socket(m_ioService));
auto socket = make_shared<RLPXSocket>(m_ioService);
socket->ref().async_connect(ep, [=](boost::system::error_code const& ec)
{
_p->m_lastAttempted = std::chrono::system_clock::now();

3
libp2p/RLPXSocket.h

@ -39,8 +39,7 @@ namespace p2p
class RLPXSocket: public std::enable_shared_from_this<RLPXSocket>
{
public:
/// Constructor. Dereferences and takes ownership of _socket.
RLPXSocket(bi::tcp::socket* _socket): m_socket(std::move(*_socket)) {}
RLPXSocket(ba::io_service& _ioService): m_socket(_ioService) {}
~RLPXSocket() { close(); }
bool isConnected() const { return m_socket.is_open(); }

Loading…
Cancel
Save