diff --git a/src/ripple/app/main/GRPCServer.cpp b/src/ripple/app/main/GRPCServer.cpp index 7279bc32b..ddaea14c2 100644 --- a/src/ripple/app/main/GRPCServer.cpp +++ b/src/ripple/app/main/GRPCServer.cpp @@ -144,11 +144,11 @@ GRPCServerImpl::CallData::process( { auto usage = getUsage(); bool isUnlimited = clientIsUnlimited(); - if (!isUnlimited && usage.disconnect()) + if (!isUnlimited && usage.disconnect(app_.journal("gRPCServer"))) { grpc::Status status{ grpc::StatusCode::RESOURCE_EXHAUSTED, - "usage balance exceeds threshhold"}; + "usage balance exceeds threshold"}; responder_.FinishWithError(status, this); } else diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 6771db089..47e03a76b 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -190,7 +190,7 @@ OverlayImpl::onHandoff( auto consumer = m_resourceManager.newInboundEndpoint( beast::IPAddressConversion::from_asio(remote_endpoint)); - if (consumer.disconnect()) + if (consumer.disconnect(journal)) return handoff; auto const slot = m_peerFinder->new_inbound_slot( @@ -392,7 +392,7 @@ OverlayImpl::connect(beast::IP::Endpoint const& remote_endpoint) assert(work_); auto usage = resourceManager().newOutboundEndpoint(remote_endpoint); - if (usage.disconnect()) + if (usage.disconnect(journal_)) { JLOG(journal_.info()) << "Over resource limit: " << remote_endpoint; return; diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index 0a2d060bb..f07381b38 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -342,8 +342,8 @@ PeerImp::removeTxQueue(uint256 const& hash) void PeerImp::charge(Resource::Charge const& fee) { - if ((usage_.charge(fee) == Resource::drop) && usage_.disconnect() && - strand_.running_in_this_thread()) + if ((usage_.charge(fee) == Resource::drop) && + usage_.disconnect(p_journal_) && strand_.running_in_this_thread()) { // Sever the connection overlay_.incPeerDisconnectCharges(); diff --git a/src/ripple/resource/Consumer.h b/src/ripple/resource/Consumer.h index 4ef916a50..34fb02ee6 100644 --- a/src/ripple/resource/Consumer.h +++ b/src/ripple/resource/Consumer.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_RESOURCE_CONSUMER_H_INCLUDED #define RIPPLE_RESOURCE_CONSUMER_H_INCLUDED +#include #include #include @@ -76,7 +77,7 @@ public: /** Returns `true` if the consumer should be disconnected. */ bool - disconnect(); + disconnect(beast::Journal const& j); /** Returns the credit balance representing consumption. */ int diff --git a/src/ripple/resource/impl/Consumer.cpp b/src/ripple/resource/impl/Consumer.cpp index fc4e35535..34edbbfcc 100644 --- a/src/ripple/resource/impl/Consumer.cpp +++ b/src/ripple/resource/impl/Consumer.cpp @@ -114,10 +114,15 @@ Consumer::warn() } bool -Consumer::disconnect() +Consumer::disconnect(beast::Journal const& j) { assert(m_entry != nullptr); - return m_logic->disconnect(*m_entry); + bool const d = m_logic->disconnect(*m_entry); + if (d) + { + JLOG(j.debug()) << "disconnecting " << m_entry->to_string(); + } + return d; } int diff --git a/src/ripple/rpc/impl/ServerHandlerImp.cpp b/src/ripple/rpc/impl/ServerHandlerImp.cpp index b9b2637eb..6fccb89cc 100644 --- a/src/ripple/rpc/impl/ServerHandlerImp.cpp +++ b/src/ripple/rpc/impl/ServerHandlerImp.cpp @@ -384,7 +384,7 @@ ServerHandlerImp::processSession( Json::Value const& jv) { auto is = std::static_pointer_cast(session->appDefined); - if (is->getConsumer().disconnect()) + if (is->getConsumer().disconnect(m_journal)) { session->close( {boost::beast::websocket::policy_error, "threshold exceeded"}); @@ -687,7 +687,7 @@ ServerHandlerImp::processRequest( { usage = m_resourceManager.newInboundEndpoint( remoteIPAddress, role == Role::PROXY, forwardedFor); - if (usage.disconnect()) + if (usage.disconnect(m_journal)) { if (!batch) { diff --git a/src/test/resource/Logic_test.cpp b/src/test/resource/Logic_test.cpp index 719cce620..25379370f 100644 --- a/src/test/resource/Logic_test.cpp +++ b/src/test/resource/Logic_test.cpp @@ -146,7 +146,7 @@ public: if (c.charge(fee) == drop) { // Disconnect abusive Consumer - BEAST_EXPECT(c.disconnect() == limited); + BEAST_EXPECT(c.disconnect(j) == limited); break; } ++logic.clock();