mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 14:05:51 +00:00
Log when we would disconnected, but don't actually disconnect for now.
This commit is contained in:
@@ -124,7 +124,10 @@ void LoadManager::canonicalize(LoadSource& source, int now) const
|
||||
{
|
||||
source.mBalance += mCreditRate * (now - source.mLastUpdate);
|
||||
if (source.mBalance > mCreditLimit)
|
||||
{
|
||||
source.mBalance = mCreditLimit;
|
||||
source.mLogged = false;
|
||||
}
|
||||
}
|
||||
source.mLastUpdate = now;
|
||||
}
|
||||
@@ -154,6 +157,9 @@ bool LoadManager::shouldCutoff(LoadSource& source) const
|
||||
canonicalize(source, now);
|
||||
if (source.isPrivileged() || (source.mBalance > mDebitLimit))
|
||||
return false;
|
||||
if (source.mLogged)
|
||||
return true;
|
||||
source.mLogged = true;
|
||||
}
|
||||
logDisconnect(source.getName());
|
||||
return true;
|
||||
|
||||
@@ -66,11 +66,14 @@ protected:
|
||||
int mFlags;
|
||||
int mLastUpdate;
|
||||
int mLastWarning;
|
||||
bool mLogged;
|
||||
|
||||
public:
|
||||
LoadSource(bool admin) : mBalance(0), mFlags(admin ? lsfPrivileged : 0), mLastUpdate(upTime()), mLastWarning(0)
|
||||
LoadSource(bool admin) :
|
||||
mBalance(0), mFlags(admin ? lsfPrivileged : 0), mLastUpdate(upTime()), mLastWarning(0), mLogged(false)
|
||||
{ ; }
|
||||
LoadSource(const std::string& name) : mName(name), mBalance(0), mFlags(0), mLastUpdate(upTime()), mLastWarning(0)
|
||||
LoadSource(const std::string& name) :
|
||||
mName(name), mBalance(0), mFlags(0), mLastUpdate(upTime()), mLastWarning(0), mLogged(false)
|
||||
{ ; }
|
||||
|
||||
void rename(const std::string& name) { mName = name; }
|
||||
@@ -80,6 +83,9 @@ public:
|
||||
void setPrivileged() { mFlags |= lsfPrivileged; }
|
||||
int getBalance() const { return mBalance; }
|
||||
|
||||
bool isLogged() const { return mLogged; }
|
||||
void clearLogged() { mLogged = false; }
|
||||
|
||||
void setOutbound() { mFlags |= lsfOutbound; }
|
||||
bool isOutbound() const { return (mFlags & lsfOutbound) != 0; }
|
||||
};
|
||||
|
||||
@@ -90,10 +90,12 @@ public:
|
||||
{
|
||||
if (theApp->getLoadManager().shouldCutoff(mLoadSource))
|
||||
{
|
||||
#if SHOULD_DISCONNECT
|
||||
connection_ptr ptr = mConnection.lock();
|
||||
if (ptr)
|
||||
ptr->close(websocketpp::close::status::PROTOCOL_ERROR, "overload");
|
||||
return rpcError(rpcSLOW_DOWN);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!jvRequest.isMember("command"))
|
||||
|
||||
Reference in New Issue
Block a user