mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-19 01:34:57 +00:00
limit on max number of concurrent REQs
This commit is contained in:
@ -40,7 +40,7 @@ struct ActiveMonitors : NonCopyable {
|
||||
|
||||
|
||||
public:
|
||||
void addSub(lmdb::txn &txn, Subscription &&sub, uint64_t currEventId) {
|
||||
bool addSub(lmdb::txn &txn, Subscription &&sub, uint64_t currEventId) {
|
||||
if (sub.latestEventId != currEventId) throw herr("sub not up to date");
|
||||
|
||||
{
|
||||
@ -51,10 +51,15 @@ struct ActiveMonitors : NonCopyable {
|
||||
auto res = conns.try_emplace(sub.connId);
|
||||
auto &connMonitors = res.first->second;
|
||||
|
||||
if (connMonitors.size() >= cfg().relay__maxSubsPerConnection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto subId = sub.subId;
|
||||
auto *m = &connMonitors.try_emplace(subId, sub).first->second;
|
||||
|
||||
installLookups(m, currEventId);
|
||||
return true;
|
||||
}
|
||||
|
||||
void removeSub(uint64_t connId, const SubId &subId) {
|
||||
|
Reference in New Issue
Block a user