diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 1d4de6eaa..0c97b3805 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3533,7 +3533,7 @@ tl_object_ptr Td::get_connection_state_object(StateMana case StateManager::State::Ready: return make_tl_object(); default: - UNREACHABLE(); + LOG(FATAL) << "State = " << static_cast(state); return nullptr; } } @@ -3543,6 +3543,9 @@ void Td::on_connection_state_changed(StateManager::State new_state) { LOG(ERROR) << "State manager sends update about unchanged state " << static_cast(new_state); return; } + if (G()->close_flag()) { + return; + } connection_state_ = new_state; send_closure(actor_id(this), &Td::send_update, @@ -4105,7 +4108,6 @@ void Td::init_options_and_network() { state_manager_ = create_actor("State manager", create_reference()); send_closure(state_manager_, &StateManager::add_callback, make_unique(create_reference())); G()->set_state_manager(state_manager_.get()); - connection_state_ = StateManager::State::Empty; VLOG(td_init) << "Create ConfigShared"; G()->set_shared_config(td::make_unique(G()->td_db()->get_config_pmc_shared())); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 2349a12e0..ea3aa340d 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -278,7 +278,7 @@ class Td final : public Actor { TdParameters parameters_; - StateManager::State connection_state_; + StateManager::State connection_state_ = StateManager::State::Empty; std::unordered_multiset request_set_; int actor_refcnt_ = 0;