Improve field names.

This commit is contained in:
levlam 2023-10-23 14:10:39 +03:00
parent 0db2644011
commit 66757e2511
4 changed files with 20 additions and 19 deletions

View File

@ -233,7 +233,7 @@ bool Session::PriorityQueue::empty() const {
Session::Session(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared> shared_auth_data, int32 raw_dc_id, Session::Session(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared> shared_auth_data, int32 raw_dc_id,
int32 dc_id, bool is_primary, bool is_main, bool use_pfs, bool persist_tmp_auth_key, bool is_cdn, int32 dc_id, bool is_primary, bool is_main, bool use_pfs, bool persist_tmp_auth_key, bool is_cdn,
bool need_destroy, const mtproto::AuthKey &tmp_auth_key, bool need_destroy_auth_key, const mtproto::AuthKey &tmp_auth_key,
const vector<mtproto::ServerSalt> &server_salts) const vector<mtproto::ServerSalt> &server_salts)
: raw_dc_id_(raw_dc_id) : raw_dc_id_(raw_dc_id)
, dc_id_(dc_id) , dc_id_(dc_id)
@ -241,9 +241,9 @@ Session::Session(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared>
, is_main_(is_main) , is_main_(is_main)
, persist_tmp_auth_key_(use_pfs && persist_tmp_auth_key) , persist_tmp_auth_key_(use_pfs && persist_tmp_auth_key)
, is_cdn_(is_cdn) , is_cdn_(is_cdn)
, need_destroy_(need_destroy) { , need_destroy_auth_key_(need_destroy_auth_key) {
VLOG(dc) << "Start connection " << tag("need_destroy", need_destroy_); VLOG(dc) << "Start connection " << tag("need_destroy_auth_key", need_destroy_auth_key_);
if (need_destroy_) { if (need_destroy_auth_key_) {
use_pfs = false; use_pfs = false;
CHECK(!is_cdn); CHECK(!is_cdn);
} }
@ -292,7 +292,7 @@ bool Session::is_high_loaded() {
} }
bool Session::can_destroy_auth_key() const { bool Session::can_destroy_auth_key() const {
return need_destroy_; return need_destroy_auth_key_;
} }
void Session::start_up() { void Session::start_up() {
@ -635,7 +635,7 @@ void Session::on_closed(Status status) {
auth_data_.drop_main_auth_key(); auth_data_.drop_main_auth_key();
on_auth_key_updated(); on_auth_key_updated();
on_session_failed(status.clone()); on_session_failed(status.clone());
} else if (need_destroy_) { } else if (need_destroy_auth_key_) {
LOG(WARNING) << "Session connection was closed, because main auth_key has been successfully destroyed"; LOG(WARNING) << "Session connection was closed, because main auth_key has been successfully destroyed";
auth_data_.drop_main_auth_key(); auth_data_.drop_main_auth_key();
on_auth_key_updated(); on_auth_key_updated();
@ -1511,7 +1511,7 @@ void Session::loop() {
if (cached_connection_timestamp_ < now - 10) { if (cached_connection_timestamp_ < now - 10) {
cached_connection_.reset(); cached_connection_.reset();
} }
if (!is_main_ && !has_queries() && !need_destroy_ && last_activity_timestamp_ < now - ACTIVITY_TIMEOUT) { if (!is_main_ && !has_queries() && !need_destroy_auth_key_ && last_activity_timestamp_ < now - ACTIVITY_TIMEOUT) {
on_session_failed(Status::OK()); on_session_failed(Status::OK());
} }

View File

@ -68,8 +68,9 @@ class Session final
}; };
Session(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared> shared_auth_data, int32 raw_dc_id, int32 dc_id, Session(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared> shared_auth_data, int32 raw_dc_id, int32 dc_id,
bool is_primary, bool is_main, bool use_pfs, bool persist_tmp_auth_key, bool is_cdn, bool need_destroy, bool is_primary, bool is_main, bool use_pfs, bool persist_tmp_auth_key, bool is_cdn,
const mtproto::AuthKey &tmp_auth_key, const vector<mtproto::ServerSalt> &server_salts); bool need_destroy_auth_key, const mtproto::AuthKey &tmp_auth_key,
const vector<mtproto::ServerSalt> &server_salts);
void send(NetQueryPtr &&query); void send(NetQueryPtr &&query);
@ -115,7 +116,7 @@ class Session final
const bool is_main_; // true only for the primary Session(s) to the main DC const bool is_main_; // true only for the primary Session(s) to the main DC
const bool persist_tmp_auth_key_; const bool persist_tmp_auth_key_;
const bool is_cdn_; const bool is_cdn_;
const bool need_destroy_; const bool need_destroy_auth_key_;
bool was_on_network_ = false; bool was_on_network_ = false;
bool network_flag_ = false; bool network_flag_ = false;
bool online_flag_ = false; bool online_flag_ = false;

View File

@ -93,7 +93,7 @@ class SessionCallback final : public Session::Callback {
SessionProxy::SessionProxy(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared> shared_auth_data, SessionProxy::SessionProxy(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared> shared_auth_data,
bool is_primary, bool is_main, bool allow_media_only, bool is_media, bool use_pfs, bool is_primary, bool is_main, bool allow_media_only, bool is_media, bool use_pfs,
bool persist_tmp_auth_key, bool is_cdn, bool need_destroy) bool persist_tmp_auth_key, bool is_cdn, bool need_destroy_auth_key)
: callback_(std::move(callback)) : callback_(std::move(callback))
, auth_data_(std::move(shared_auth_data)) , auth_data_(std::move(shared_auth_data))
, is_primary_(is_primary) , is_primary_(is_primary)
@ -103,7 +103,7 @@ SessionProxy::SessionProxy(unique_ptr<Callback> callback, std::shared_ptr<AuthDa
, use_pfs_(use_pfs) , use_pfs_(use_pfs)
, persist_tmp_auth_key_(use_pfs && persist_tmp_auth_key) , persist_tmp_auth_key_(use_pfs && persist_tmp_auth_key)
, is_cdn_(is_cdn) , is_cdn_(is_cdn)
, need_destroy_(need_destroy) { , need_destroy_auth_key_(need_destroy_auth_key) {
} }
void SessionProxy::start_up() { void SessionProxy::start_up() {
@ -173,11 +173,11 @@ void SessionProxy::update_main_flag(bool is_main) {
} }
void SessionProxy::destroy_auth_key() { void SessionProxy::destroy_auth_key() {
if (need_destroy_) { if (need_destroy_auth_key_) {
LOG(INFO) << "Ignore reduntant destroy_auth_key"; LOG(INFO) << "Ignore reduntant destroy_auth_key";
return; return;
} }
need_destroy_ = true; need_destroy_auth_key_ = true;
close_session(); close_session();
open_session(); open_session();
} }
@ -215,7 +215,7 @@ void SessionProxy::open_session(bool force) {
if (force) { if (force) {
return true; return true;
} }
if (need_destroy_) { if (need_destroy_auth_key_) {
return auth_key_state_ != AuthKeyState::Empty; return auth_key_state_ != AuthKeyState::Empty;
} }
if (is_main_) { if (is_main_) {
@ -246,8 +246,8 @@ void SessionProxy::open_session(bool force) {
session_ = create_actor<Session>( session_ = create_actor<Session>(
name, name,
make_unique<SessionCallback>(actor_shared(this, session_generation_), dc_id, allow_media_only_, is_media_, hash), make_unique<SessionCallback>(actor_shared(this, session_generation_), dc_id, allow_media_only_, is_media_, hash),
auth_data_, raw_dc_id, int_dc_id, is_primary_, is_main_, use_pfs_, persist_tmp_auth_key_, is_cdn_, need_destroy_, auth_data_, raw_dc_id, int_dc_id, is_primary_, is_main_, use_pfs_, persist_tmp_auth_key_, is_cdn_,
tmp_auth_key_, server_salts_); need_destroy_auth_key_, tmp_auth_key_, server_salts_);
} }
void SessionProxy::update_auth_key_state() { void SessionProxy::update_auth_key_state() {

View File

@ -34,7 +34,7 @@ class SessionProxy final : public Actor {
SessionProxy(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared> shared_auth_data, bool is_primary, SessionProxy(unique_ptr<Callback> callback, std::shared_ptr<AuthDataShared> shared_auth_data, bool is_primary,
bool is_main, bool allow_media_only, bool is_media, bool use_pfs, bool persist_tmp_auth_key, bool is_cdn, bool is_main, bool allow_media_only, bool is_media, bool use_pfs, bool persist_tmp_auth_key, bool is_cdn,
bool need_destroy); bool need_destroy_auth_key);
void send(NetQueryPtr query); void send(NetQueryPtr query);
@ -57,7 +57,7 @@ class SessionProxy final : public Actor {
mtproto::AuthKey tmp_auth_key_; mtproto::AuthKey tmp_auth_key_;
std::vector<mtproto::ServerSalt> server_salts_; std::vector<mtproto::ServerSalt> server_salts_;
bool is_cdn_; bool is_cdn_;
bool need_destroy_; bool need_destroy_auth_key_;
ActorOwn<Session> session_; ActorOwn<Session> session_;
std::vector<NetQueryPtr> pending_queries_; std::vector<NetQueryPtr> pending_queries_;
uint64 session_generation_ = 1; uint64 session_generation_ = 1;