diff --git a/src/cpp/ripple/LoadManager.cpp b/src/cpp/ripple/LoadManager.cpp index 5384df4bda..41d15ac94c 100644 --- a/src/cpp/ripple/LoadManager.cpp +++ b/src/cpp/ripple/LoadManager.cpp @@ -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; diff --git a/src/cpp/ripple/LoadManager.h b/src/cpp/ripple/LoadManager.h index 070384d702..25b8aa5855 100644 --- a/src/cpp/ripple/LoadManager.h +++ b/src/cpp/ripple/LoadManager.h @@ -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; } }; diff --git a/src/cpp/ripple/WSConnection.h b/src/cpp/ripple/WSConnection.h index bc928d713c..6f3aa2cd2d 100644 --- a/src/cpp/ripple/WSConnection.h +++ b/src/cpp/ripple/WSConnection.h @@ -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"))