mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 11:15:56 +00:00
Log resource limit disconnections.
This commit is contained in:
@@ -144,11 +144,11 @@ GRPCServerImpl::CallData<Request, Response>::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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef RIPPLE_RESOURCE_CONSUMER_H_INCLUDED
|
||||
#define RIPPLE_RESOURCE_CONSUMER_H_INCLUDED
|
||||
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/resource/Charge.h>
|
||||
#include <ripple/resource/Disposition.h>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -384,7 +384,7 @@ ServerHandlerImp::processSession(
|
||||
Json::Value const& jv)
|
||||
{
|
||||
auto is = std::static_pointer_cast<WSInfoSub>(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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user