mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix the bug I introduced with the last few changes (deadlock in ConnectionPool).
This commit is contained in:
@@ -313,7 +313,7 @@ Peer::pointer ConnectionPool::peerConnect(const std::string& strIp, int iPort)
|
||||
|
||||
if ((it = mIpMap.find(pipPeer)) == mIpMap.end())
|
||||
{
|
||||
Peer::pointer ppNew(Peer::create(theApp->getIOService(), mCtx));
|
||||
Peer::pointer ppNew(Peer::create(theApp->getIOService(), mCtx, ++mLastPeer));
|
||||
|
||||
// Did not find it. Not already connecting or connected.
|
||||
ppNew->connect(strIp, iPort);
|
||||
|
||||
@@ -24,14 +24,14 @@ DECLARE_INSTANCE(Peer);
|
||||
// Node has this long to verify its identity from connection accepted or connection attempt.
|
||||
#define NODE_VERIFY_SECONDS 15
|
||||
|
||||
Peer::Peer(boost::asio::io_service& io_service, boost::asio::ssl::context& ctx) :
|
||||
Peer::Peer(boost::asio::io_service& io_service, boost::asio::ssl::context& ctx, uint64 peerID) :
|
||||
mHelloed(false),
|
||||
mDetaching(false),
|
||||
mPeerId(peerID),
|
||||
mSocketSsl(io_service, ctx),
|
||||
mVerifyTimer(io_service)
|
||||
{
|
||||
cLog(lsDEBUG) << "CREATING PEER: " << ADDRESS(this);
|
||||
mPeerId = theApp->getConnectionPool().assignPeerId();
|
||||
}
|
||||
|
||||
void Peer::handle_write(const boost::system::error_code& error, size_t bytes_transferred)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "../obj/src/ripple.pb.h"
|
||||
@@ -72,7 +73,7 @@ protected:
|
||||
ripple::TMStatusChange mLastStatus;
|
||||
ripple::TMHello mHello;
|
||||
|
||||
Peer(boost::asio::io_service& io_service, boost::asio::ssl::context& ctx);
|
||||
Peer(boost::asio::io_service& io_service, boost::asio::ssl::context& ctx, uint64 peerId);
|
||||
|
||||
void handleShutdown(const boost::system::error_code& error) { ; }
|
||||
static void sHandleShutdown(Peer::ref ptr, const boost::system::error_code& error)
|
||||
@@ -132,9 +133,9 @@ public:
|
||||
|
||||
void setIpPort(const std::string& strIP, int iPort);
|
||||
|
||||
static pointer create(boost::asio::io_service& io_service, boost::asio::ssl::context& ctx)
|
||||
static pointer create(boost::asio::io_service& io_service, boost::asio::ssl::context& ctx, uint64 id)
|
||||
{
|
||||
return pointer(new Peer(io_service, ctx));
|
||||
return pointer(new Peer(io_service, ctx, id));
|
||||
}
|
||||
|
||||
boost::asio::ssl::stream<boost::asio::ip::tcp::socket>::lowest_layer_type& getSocket()
|
||||
|
||||
@@ -39,7 +39,8 @@ PeerDoor::PeerDoor(boost::asio::io_service& io_service) :
|
||||
|
||||
void PeerDoor::startListening()
|
||||
{
|
||||
Peer::pointer new_connection = Peer::create(mAcceptor.get_io_service(), mCtx);
|
||||
Peer::pointer new_connection = Peer::create(mAcceptor.get_io_service(), mCtx,
|
||||
theApp->getConnectionPool().assignPeerId());
|
||||
|
||||
mAcceptor.async_accept(new_connection->getSocket(),
|
||||
boost::bind(&PeerDoor::handleConnect, this, new_connection,
|
||||
|
||||
Reference in New Issue
Block a user