ConnectionCreator: relax flood limits for errors during creation of a connection
GitOrigin-RevId: e92d62461e0b3eeab77f1b92ef8c99d630bf3b74
This commit is contained in:
parent
3fb9b8a992
commit
c489d7187e
@ -90,6 +90,8 @@ class StatsCallback final : public mtproto::RawConnection::StatsCallback {
|
||||
} // namespace detail
|
||||
|
||||
ConnectionCreator::ClientInfo::ClientInfo() {
|
||||
sanity_flood_control.add_limit(5, 10);
|
||||
|
||||
flood_control.add_limit(1, 1);
|
||||
flood_control.add_limit(4, 2);
|
||||
flood_control.add_limit(8, 3);
|
||||
@ -549,6 +551,7 @@ void ConnectionCreator::on_network(bool network_flag, uint32 network_generation)
|
||||
|
||||
for (auto &client : clients_) {
|
||||
client.second.backoff.clear();
|
||||
client.second.sanity_flood_control.clear_events();
|
||||
client.second.flood_control.clear_events();
|
||||
client.second.flood_control_online.clear_events();
|
||||
client_loop(client.second);
|
||||
@ -566,6 +569,7 @@ void ConnectionCreator::on_online(bool online_flag) {
|
||||
online_flag_ = online_flag;
|
||||
if (need_drop_flood_control) {
|
||||
for (auto &client : clients_) {
|
||||
client.second.sanity_flood_control.clear_events();
|
||||
client.second.backoff.clear();
|
||||
client.second.flood_control_online.clear_events();
|
||||
client_loop(client.second);
|
||||
@ -576,6 +580,7 @@ void ConnectionCreator::on_logging_out(bool is_logging_out) {
|
||||
VLOG(connections) << "Receive logging out flag " << is_logging_out;
|
||||
is_logging_out_ = is_logging_out;
|
||||
for (auto &client : clients_) {
|
||||
client.second.sanity_flood_control.clear_events();
|
||||
client.second.backoff.clear();
|
||||
client.second.flood_control_online.clear_events();
|
||||
client_loop(client.second);
|
||||
@ -865,16 +870,15 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
|
||||
// Check flood
|
||||
auto &flood_control = act_as_if_online ? client.flood_control_online : client.flood_control;
|
||||
auto wakeup_at = max(flood_control.get_wakeup_at(), client.mtproto_error_flood_control.get_wakeup_at());
|
||||
wakeup_at = max(client.sanity_flood_control.get_wakeup_at(), wakeup_at);
|
||||
|
||||
if (!act_as_if_online) {
|
||||
wakeup_at = max(wakeup_at, client.backoff.get_wakeup_at());
|
||||
}
|
||||
if (wakeup_at > Time::now()) {
|
||||
return client_set_timeout_at(client, wakeup_at);
|
||||
}
|
||||
flood_control.add_event(static_cast<int32>(Time::now()));
|
||||
if (!act_as_if_online) {
|
||||
client.backoff.add_event(static_cast<int32>(Time::now()));
|
||||
}
|
||||
client.sanity_flood_control.add_event(static_cast<int32>(Time::now()));
|
||||
|
||||
// Create new RawConnection
|
||||
// sync part
|
||||
@ -889,6 +893,12 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
|
||||
return client_set_timeout_at(client, Time::now() + 0.1);
|
||||
}
|
||||
|
||||
// Events with failed socket creation are ignored
|
||||
flood_control.add_event(static_cast<int32>(Time::now()));
|
||||
if (!act_as_if_online) {
|
||||
client.backoff.add_event(static_cast<int32>(Time::now()));
|
||||
}
|
||||
|
||||
auto socket_fd = r_socket_fd.move_as_ok();
|
||||
IPAddress debug_ip;
|
||||
auto debug_ip_status = debug_ip.init_socket_address(socket_fd);
|
||||
|
@ -147,6 +147,7 @@ class ConnectionCreator : public NetQueryCallback {
|
||||
void add_session_id(int64 session_id);
|
||||
|
||||
Backoff backoff;
|
||||
FloodControlStrict sanity_flood_control;
|
||||
FloodControlStrict flood_control;
|
||||
FloodControlStrict flood_control_online;
|
||||
FloodControlStrict mtproto_error_flood_control;
|
||||
|
Loading…
Reference in New Issue
Block a user