Session: fix key deletion in http connections

GitOrigin-RevId: ddc80efe78a0a11dee7eb21c55d7efdd76a2be1d
This commit is contained in:
Arseny Smirnov 2019-08-01 16:03:18 +03:00
parent 331c8b52c1
commit c2c32c4e2b
2 changed files with 4 additions and 6 deletions

View File

@ -283,7 +283,7 @@ Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::dest
}
Status SessionConnection::on_destroy_auth_key(const mtproto_api::DestroyAuthKeyRes &destroy_auth_key) {
CHECK(need_destroy_auth_key_);
LOG_CHECK(need_destroy_auth_key_) << static_cast<int32>(mode_);
LOG(INFO) << to_string(destroy_auth_key);
return callback_->on_destroy_auth_key();
}

View File

@ -972,6 +972,9 @@ void Session::connection_open_finish(ConnectionInfo *info,
auto name = PSTRING() << get_name() << "::Connect::" << mode_name << "::" << raw_connection->debug_str_;
LOG(INFO) << "Finished to open connection " << name;
info->connection = make_unique<mtproto::SessionConnection>(mode, std::move(raw_connection), &auth_data_);
if (can_destroy_auth_key()) {
info->connection->destroy_key();
}
info->connection->set_online(connection_online_flag_, is_main_);
info->connection->set_name(name);
Scheduler::subscribe(info->connection->get_poll_info().extract_pollable_fd(this));
@ -1206,11 +1209,6 @@ void Session::loop() {
need_flush = true;
}
}
if (can_destroy_auth_key()) {
if (main_connection_.connection) {
main_connection_.connection->destroy_key();
}
}
if (need_flush) {
connection_flush(&main_connection_);
need_flush = false;