From 6aa090a43a5c4cb142dcf970ad2b86fa28408f7b Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 26 Oct 2021 14:28:09 +0300 Subject: [PATCH] Improve MultiPromiseActorSafe usage. --- telegram-bot-api/ClientManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/telegram-bot-api/ClientManager.cpp b/telegram-bot-api/ClientManager.cpp index c4730a9..f8b0b81 100644 --- a/telegram-bot-api/ClientManager.cpp +++ b/telegram-bot-api/ClientManager.cpp @@ -417,12 +417,15 @@ void ClientManager::hangup_shared() { void ClientManager::close_db() { LOG(WARNING) << "Closing databases"; - td::MultiPromiseActorSafe mpromise("close binlogs"); - mpromise.add_promise(td::PromiseCreator::lambda( + td::MultiPromiseActorSafe mpas("close binlogs"); + mpas.add_promise(td::PromiseCreator::lambda( [actor_id = actor_id(this)](td::Unit) { send_closure(actor_id, &ClientManager::finish_close); })); + mpas.set_ignore_errors(true); - parameters_->shared_data_->tqueue_->close(mpromise.get_promise()); - parameters_->shared_data_->webhook_db_->close(mpromise.get_promise()); + auto lock = mpas.get_promise(); + parameters_->shared_data_->tqueue_->close(mpas.get_promise()); + parameters_->shared_data_->webhook_db_->close(mpas.get_promise()); + lock.set_value(td::Unit()); } void ClientManager::finish_close() {