From 12d4b6b53e182297ddae5893bfff29f482a96e53 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 27 Apr 2020 13:26:04 -0700 Subject: [PATCH] modules/client/keys: Add limits on dynamic buffer calculations. --- modules/client/keys/claim.cc | 9 ++++++++- modules/client/keys/query.cc | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/client/keys/claim.cc b/modules/client/keys/claim.cc index f08d37e7d..2da2953cf 100644 --- a/modules/client/keys/claim.cc +++ b/modules/client/keys/claim.cc @@ -118,6 +118,13 @@ claim_timeout_max { "default", 30000L }, }; +conf::item +claim_limit +{ + { "name", "ircd.client.keys.claim.limit" }, + { "default", 4096L }, +}; + m::resource::response post__keys_claim(client &client, const m::resource::request &request) @@ -281,7 +288,7 @@ try static_assert(is_powerof2(buffer_unit_size)); const size_t buffer_size { - buffer_unit_size * queries.size() + buffer_unit_size * std::min(queries.size(), size_t(claim_limit)) }; const auto &buffer diff --git a/modules/client/keys/query.cc b/modules/client/keys/query.cc index e121d2915..fb63e0b89 100644 --- a/modules/client/keys/query.cc +++ b/modules/client/keys/query.cc @@ -117,6 +117,13 @@ query_timeout_max { "default", 20000L }, }; +conf::item +query_limit +{ + { "name", "ircd.client.keys.query.limit" }, + { "default", 4096L }, +}; + m::resource::response post__keys_query(client &client, const m::resource::request &request) @@ -330,7 +337,7 @@ try const size_t buffer_size { - buffer_unit_size * queries.size() + buffer_unit_size * std::min(queries.size(), size_t(query_limit)) }; const auto &buffer