From 4d025b1c9b66f88dcbc8a51046c5dda76e79b59a Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 21 Nov 2020 17:46:18 +0300 Subject: [PATCH] Safer handling of negative monotonic time. --- telegram-bot-api/Client.cpp | 5 +++++ telegram-bot-api/WebhookActor.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index d563853..c27f721 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -3198,6 +3198,11 @@ void Client::start_up() { next_bot_updates_warning_time_ = start_time_ + 600; schedule_next_delete_messages_lru(); webhook_set_time_ = start_time_; + next_allowed_set_webhook_time_ = start_time_; + next_set_webhook_logging_time_ = start_time_; + next_webhook_is_not_modified_warning_time_ = start_time_; + previous_get_updates_start_time_ = start_time_ - 100; + previous_get_updates_finish_time_ = start_time_ - 100; sticker_set_names_[GREAT_MINDS_SET_ID] = GREAT_MINDS_SET_NAME.str(); diff --git a/telegram-bot-api/WebhookActor.cpp b/telegram-bot-api/WebhookActor.cpp index fea7de9..affaeb7 100644 --- a/telegram-bot-api/WebhookActor.cpp +++ b/telegram-bot-api/WebhookActor.cpp @@ -647,7 +647,7 @@ void WebhookActor::handle(td::unique_ptr response) { void WebhookActor::start_up() { max_loaded_updates_ = max_connections_ * 2; - last_success_time_ = td::Time::now(); + next_ip_address_resolve_time_ = last_success_time_ = td::Time::now(); active_new_connection_flood_.add_limit(1, 10 * max_connections_); active_new_connection_flood_.add_limit(5, 20 * max_connections_);