From d9607b4a4661e3b8ea7b13c6ca9f42e51d913819 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 25 Oct 2021 06:47:20 +0300 Subject: [PATCH] Use send_closure for Td::close()/destroy() to ensure the correct call order. --- td/telegram/Td.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index e166fbd28..d5af1c0e8 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3094,9 +3094,10 @@ void Td::request(uint64 id, tl_object_ptr function) { return send_result(id, td_api::make_object(std::move(updates))); } case td_api::close::ID: - // need to send response synchronously before actual closing - send_result(id, td_api::make_object()); - return close(); + // need to send response before actual closing + send_closure(actor_id(this), &Td::send_result, id, td_api::make_object()); + send_closure(actor_id(this), &Td::close); + return; default: break; } @@ -3132,8 +3133,9 @@ void Td::request(uint64 id, tl_object_ptr function) { } case td_api::destroy::ID: // need to send response synchronously before actual destroying - send_result(id, td_api::make_object()); - return destroy(); + send_closure(actor_id(this), &Td::send_result, id, td_api::make_object()); + send_closure(actor_id(this), &Td::destroy); + return; default: if (is_preinitialization_request(function_id)) { break; @@ -4513,13 +4515,13 @@ void Td::on_request(uint64 id, const td_api::logOut &request) { void Td::on_request(uint64 id, const td_api::close &request) { // send response before actually closing send_closure(actor_id(this), &Td::send_result, id, td_api::make_object()); - close(); + send_closure(actor_id(this), &Td::close); } void Td::on_request(uint64 id, const td_api::destroy &request) { // send response before actually destroying send_closure(actor_id(this), &Td::send_result, id, td_api::make_object()); - destroy(); + send_closure(actor_id(this), &Td::destroy); } void Td::on_request(uint64 id, td_api::checkAuthenticationBotToken &request) {