diff options
author | louiz’ <louiz@louiz.org> | 2018-06-26 20:42:21 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2018-06-26 20:42:21 +0200 |
commit | 0d886d5f32dda3be5827ed2c84f9bf2806b69601 (patch) | |
tree | d1374dfb87d8e228ead57f215fe35148a4ef2a07 | |
parent | 7f8a612c9881928f722fb41c75ff18b94a133ed4 (diff) | |
download | biboumi-0d886d5f32dda3be5827ed2c84f9bf2806b69601.tar.gz biboumi-0d886d5f32dda3be5827ed2c84f9bf2806b69601.tar.bz2 biboumi-0d886d5f32dda3be5827ed2c84f9bf2806b69601.tar.xz biboumi-0d886d5f32dda3be5827ed2c84f9bf2806b69601.zip |
Default the throttle limit to 10 if not built with database support
-rw-r--r-- | src/irc/irc_client.cpp | 11 | ||||
-rw-r--r-- | src/irc/irc_client.hpp | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index b89ab1c..fee6517 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -144,7 +144,7 @@ IrcClient::IrcClient(std::shared_ptr<Poller>& poller, std::string hostname, welcomed(false), chanmodes({"", "", "", ""}), chantypes({'#', '&'}), - tokens_bucket(Database::get_irc_server_options(bridge.get_bare_jid(), hostname).col<Database::ThrottleLimit>(), 1s, [this]() { + tokens_bucket(this->get_throttle_limit(), 1s, [this]() { if (message_queue.empty()) return true; this->actual_send(std::move(this->message_queue.front())); @@ -1283,3 +1283,12 @@ bool IrcClient::abort_on_invalid_cert() const return true; } #endif + +std::size_t IrcClient::get_throttle_limit() const +{ +#ifdef USE_DATABASE + return Database::get_irc_server_options(this->bridge.get_bare_jid(), this->hostname).col<Database::ThrottleLimit>(); +#else + return 10; +#endif +} diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index ac5ccb0..8c5c0c8 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -397,6 +397,7 @@ private: */ Resolver dns_resolver; TokensBucket tokens_bucket; + std::size_t get_throttle_limit() const; }; |