From c8405e95f3939080b6ae9b3c1f29eca11994d2c0 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 22 Nov 2022 16:44:30 +0300 Subject: [PATCH] Improve HttpOutboundConnection parameters. --- telegram-bot-api/WebhookActor.cpp | 8 +++++--- telegram-bot-api/WebhookActor.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/telegram-bot-api/WebhookActor.cpp b/telegram-bot-api/WebhookActor.cpp index e7fe38c..fbcaf58 100644 --- a/telegram-bot-api/WebhookActor.cpp +++ b/telegram-bot-api/WebhookActor.cpp @@ -51,8 +51,10 @@ WebhookActor::WebhookActor(td::ActorShared callback, td::int64 tqueue_ , fix_ip_address_(fix_ip_address) , from_db_flag_(from_db_flag) , max_connections_(max_connections) - , secret_token_(std::move(secret_token)) { + , secret_token_(std::move(secret_token)) + , slow_scheduler_id_(td::Scheduler::instance()->sched_count() - 2) { CHECK(max_connections_ > 0); + CHECK(slow_scheduler_id_ > 0); if (!cached_ip_address.empty()) { auto r_ip_address = td::IPAddress::get_ip_address(cached_ip_address); @@ -226,8 +228,8 @@ td::Status WebhookActor::create_connection(td::BufferedFd fd) { auto id = connections_.create(Connection()); auto *conn = connections_.get(id); conn->actor_id_ = td::create_actor( - PSLICE() << "Connect:" << id, std::move(fd), std::move(ssl_stream), std::numeric_limits::max(), 20, 60, - td::ActorShared(actor_id(this), id)); + PSLICE() << "Connect:" << id, std::move(fd), std::move(ssl_stream), 0, 20, 60, + td::ActorShared(actor_id(this), id), slow_scheduler_id_); conn->ip_generation_ = ip_generation_; conn->event_id_ = {}; conn->id_ = id; diff --git a/telegram-bot-api/WebhookActor.h b/telegram-bot-api/WebhookActor.h index 2538cc0..462384f 100644 --- a/telegram-bot-api/WebhookActor.h +++ b/telegram-bot-api/WebhookActor.h @@ -172,6 +172,7 @@ class WebhookActor final : public td::HttpOutboundConnection::Callback { double last_success_time_ = 0; double wakeup_at_ = 0; bool last_update_was_successful_ = true; + td::int32 slow_scheduler_id_ = -1; void relax_wakeup_at(double wakeup_at, const char *source);