ConfigManager: minor refactoring for hangup_shared
GitOrigin-RevId: 56af208cbe2e32120fa286b9e19fce58beaf8c9b
This commit is contained in:
parent
6a30258d39
commit
1d56a371cd
@ -880,8 +880,7 @@ ConfigManager::ConfigManager(ActorShared<> parent) : parent_(std::move(parent))
|
||||
}
|
||||
|
||||
void ConfigManager::start_up() {
|
||||
ref_cnt_++;
|
||||
config_recoverer_ = create_actor<ConfigRecoverer>("Recoverer", actor_shared());
|
||||
config_recoverer_ = create_actor<ConfigRecoverer>("Recoverer", create_reference());
|
||||
send_closure(config_recoverer_, &ConfigRecoverer::on_dc_options_update, load_dc_options_update());
|
||||
|
||||
auto expire_time = load_config_expire_time();
|
||||
@ -893,7 +892,13 @@ void ConfigManager::start_up() {
|
||||
}
|
||||
}
|
||||
|
||||
ActorShared<> ConfigManager::create_reference() {
|
||||
ref_cnt_++;
|
||||
return actor_shared(this, REFCNT_TOKEN);
|
||||
}
|
||||
|
||||
void ConfigManager::hangup_shared() {
|
||||
LOG_CHECK(get_link_token() == REFCNT_TOKEN) << "Expected REFCNT_TOKEN, got " << get_link_token();
|
||||
ref_cnt_--;
|
||||
try_stop();
|
||||
}
|
||||
|
@ -131,6 +131,8 @@ class ConfigManager : public NetQueryCallback {
|
||||
size_t dismiss_suggested_action_request_count_ = 0;
|
||||
std::map<SuggestedAction, vector<Promise<Unit>>> dismiss_suggested_action_queries_;
|
||||
|
||||
static constexpr uint64 REFCNT_TOKEN = std::numeric_limits<uint64>::max() - 2;
|
||||
|
||||
void start_up() override;
|
||||
void hangup_shared() override;
|
||||
void hangup() override;
|
||||
@ -157,6 +159,8 @@ class ConfigManager : public NetQueryCallback {
|
||||
static void save_config_expire(Timestamp timestamp);
|
||||
static void save_dc_options_update(DcOptions dc_options);
|
||||
static DcOptions load_dc_options_update();
|
||||
|
||||
ActorShared<> create_reference();
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -684,8 +684,6 @@ void Session::mark_as_unknown(uint64 id, Query *query) {
|
||||
}
|
||||
|
||||
Status Session::on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) {
|
||||
// Steal authorization information.
|
||||
// It is a dirty hack, yep.
|
||||
if (id == 0) {
|
||||
if (is_cdn_) {
|
||||
return Status::Error("Got update from CDN connection");
|
||||
@ -718,6 +716,8 @@ Status Session::on_message_result_ok(uint64 id, BufferSlice packet, size_t origi
|
||||
VLOG(net_query) << "Return query result " << query_ptr->query;
|
||||
|
||||
if (!parser.get_error()) {
|
||||
// Steal authorization information.
|
||||
// It is a dirty hack, yep.
|
||||
if (ID == telegram_api::auth_authorization::ID || ID == telegram_api::auth_loginTokenSuccess::ID) {
|
||||
if (query_ptr->query->tl_constructor() != telegram_api::auth_importAuthorization::ID) {
|
||||
G()->net_query_dispatcher().set_main_dc_id(raw_dc_id_);
|
||||
|
Loading…
x
Reference in New Issue
Block a user