Destroy authorization keys: fixes
GitOrigin-RevId: 9538efa2deadda91c18c1c97aa22281597a44d4b
This commit is contained in:
parent
34a26188c6
commit
7471e62740
@ -3521,7 +3521,7 @@ void Td::on_connection_state_changed(StateManager::State new_state) {
|
||||
|
||||
void Td::on_authorization_lost() {
|
||||
LOG(WARNING) << "on_authorization_lost";
|
||||
destroy();
|
||||
send_closure(auth_manager_actor_, &AuthManager::on_authorization_lost);
|
||||
}
|
||||
|
||||
void Td::start_up() {
|
||||
|
@ -111,6 +111,7 @@ Session::Session(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared>
|
||||
bool is_main, bool use_pfs, bool is_cdn, bool need_destroy, const mtproto::AuthKey &tmp_auth_key,
|
||||
std::vector<mtproto::ServerSalt> server_salts)
|
||||
: dc_id_(dc_id), is_main_(is_main), is_cdn_(is_cdn) {
|
||||
LOG(INFO) << "Open session: ";
|
||||
VLOG(dc) << "Start connection";
|
||||
need_destroy_ = need_destroy;
|
||||
if (need_destroy) {
|
||||
@ -287,6 +288,7 @@ void Session::flush_pending_invoke_after_queries() {
|
||||
}
|
||||
|
||||
void Session::close() {
|
||||
LOG(INFO) << "Close session (external)";
|
||||
close_flag_ = true;
|
||||
connection_close(&main_connection_);
|
||||
connection_close(&long_poll_connection_);
|
||||
@ -669,7 +671,7 @@ void Session::on_message_result_error(uint64 id, int error_code, BufferSlice mes
|
||||
LOG(WARNING) << "Lost authorization due to " << tag("msg", message.as_slice());
|
||||
auth_data_.set_auth_flag(false);
|
||||
shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key());
|
||||
auth_lost_flag_ = true;
|
||||
on_session_failed(Status::OK());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1166,7 +1168,6 @@ void Session::loop() {
|
||||
main_connection_.wakeup_at = 0;
|
||||
long_poll_connection_.wakeup_at = 0;
|
||||
|
||||
auth_lost_flag_ = false;
|
||||
// NB: order is crucial. First long_poll_connection, then main_connection
|
||||
// Otherwise queries could be sent with big delay
|
||||
|
||||
@ -1219,13 +1220,6 @@ void Session::loop() {
|
||||
connection_open(&main_connection_, true /*send ask_info*/);
|
||||
}
|
||||
|
||||
if (auth_lost_flag_) {
|
||||
connection_close(&main_connection_);
|
||||
connection_close(&long_poll_connection_);
|
||||
auth_lost_flag_ = false;
|
||||
relax_timeout_at(&wakeup_at, Time::now_cached() + 0.1);
|
||||
}
|
||||
|
||||
relax_timeout_at(&wakeup_at, main_connection_.wakeup_at);
|
||||
|
||||
double wakeup_in = 0;
|
||||
|
@ -136,7 +136,6 @@ class Session final
|
||||
ConnectionInfo *current_info_;
|
||||
ConnectionInfo main_connection_;
|
||||
ConnectionInfo long_poll_connection_;
|
||||
bool auth_lost_flag_ = false;
|
||||
StateManager::ConnectionToken connection_token_;
|
||||
|
||||
double cached_connection_timestamp_ = 0;
|
||||
|
@ -57,9 +57,7 @@ void SessionMultiProxy::update_main_flag(bool is_main) {
|
||||
|
||||
void SessionMultiProxy::update_destroy_auth_key(bool need_destroy_auth_key) {
|
||||
need_destroy_auth_key_ = need_destroy_auth_key;
|
||||
for (auto &session : sessions_) {
|
||||
send_closure(session, &SessionProxy::update_destroy, need_destroy_auth_key_);
|
||||
}
|
||||
send_closure(sessions_[0], &SessionProxy::update_destroy, need_destroy_auth_key_);
|
||||
}
|
||||
void SessionMultiProxy::update_session_count(int32 session_count) {
|
||||
update_options(session_count, use_pfs_);
|
||||
@ -120,7 +118,7 @@ void SessionMultiProxy::init() {
|
||||
<< format::cond(session_count_ > 1, format::concat("#", i));
|
||||
sessions_.push_back(create_actor<SessionProxy>(name, auth_data_, is_main_, allow_media_only_, is_media_,
|
||||
get_pfs_flag(), is_main_ && i != 0, is_cdn_,
|
||||
need_destroy_auth_key_));
|
||||
need_destroy_auth_key_ && i == 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,13 +165,10 @@ void SessionProxy::open_session(bool force) {
|
||||
if (need_destroy_) {
|
||||
return auth_state_ != AuthState::Empty;
|
||||
}
|
||||
if (is_main_) { // always open main for ordinary queries
|
||||
return true;
|
||||
if (auth_state_ != AuthState::OK) {
|
||||
return false;
|
||||
}
|
||||
if (!pending_queries_.empty() && auth_state_ == AuthState::OK) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return is_main_ || !pending_queries_.empty();
|
||||
}();
|
||||
if (!should_open) {
|
||||
return;
|
||||
@ -196,7 +193,11 @@ void SessionProxy::open_session(bool force) {
|
||||
}
|
||||
|
||||
void SessionProxy::update_auth_state() {
|
||||
auto old_auth_state = auth_state_;
|
||||
auth_state_ = auth_data_->get_auth_state().first;
|
||||
if (auth_state_ != old_auth_state && old_auth_state == AuthState::OK) {
|
||||
close_session();
|
||||
}
|
||||
open_session();
|
||||
if (session_.empty() || auth_state_ != AuthState::OK) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user