From d3846adaa21dc7e46c672979feb5316c4dc66aea Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 23 Jan 2023 19:27:19 +0300 Subject: [PATCH] Destroy HttpQuery on another thread. --- telegram-bot-api/Query.h | 2 ++ telegram-bot-api/WebhookActor.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/telegram-bot-api/Query.h b/telegram-bot-api/Query.h index 8d79aba..66c8e55 100644 --- a/telegram-bot-api/Query.h +++ b/telegram-bot-api/Query.h @@ -114,6 +114,8 @@ class Query final : public td::ListNode { if (!empty()) { shared_data_->query_list_size_.fetch_sub(1, std::memory_order_relaxed); } + td::Scheduler::instance()->destroy_on_scheduler(SharedData::get_file_gc_scheduler_id(), container_, args_, + headers_, files_, answer_); } } diff --git a/telegram-bot-api/WebhookActor.cpp b/telegram-bot-api/WebhookActor.cpp index 318390c..e21e114 100644 --- a/telegram-bot-api/WebhookActor.cpp +++ b/telegram-bot-api/WebhookActor.cpp @@ -590,6 +590,11 @@ void WebhookActor::send_updates() { } void WebhookActor::handle(td::unique_ptr response) { + SCOPE_EXIT { + bool dummy = false; + td::Scheduler::instance()->destroy_on_scheduler(SharedData::get_file_gc_scheduler_id(), response, dummy); + }; + auto connection_id = get_link_token(); if (response) { VLOG(webhook) << "Got response from connection " << connection_id;