Forcely disable multiple sessions and PFS while destroying auth key.
This commit is contained in:
parent
9fdc48ac2d
commit
4786d1a931
@ -226,7 +226,8 @@ void NetQueryDispatcher::update_session_count() {
|
|||||||
bool use_pfs = get_use_pfs();
|
bool use_pfs = get_use_pfs();
|
||||||
for (size_t i = 1; i < MAX_DC_COUNT; i++) {
|
for (size_t i = 1; i < MAX_DC_COUNT; i++) {
|
||||||
if (is_dc_inited(narrow_cast<int32>(i))) {
|
if (is_dc_inited(narrow_cast<int32>(i))) {
|
||||||
send_closure_later(dcs_[i - 1].main_session_, &SessionMultiProxy::update_options, session_count, use_pfs);
|
send_closure_later(dcs_[i - 1].main_session_, &SessionMultiProxy::update_options, session_count, use_pfs,
|
||||||
|
need_destroy_auth_key_);
|
||||||
send_closure_later(dcs_[i - 1].upload_session_, &SessionMultiProxy::update_use_pfs, use_pfs);
|
send_closure_later(dcs_[i - 1].upload_session_, &SessionMultiProxy::update_use_pfs, use_pfs);
|
||||||
send_closure_later(dcs_[i - 1].download_session_, &SessionMultiProxy::update_use_pfs, use_pfs);
|
send_closure_later(dcs_[i - 1].download_session_, &SessionMultiProxy::update_use_pfs, use_pfs);
|
||||||
send_closure_later(dcs_[i - 1].download_small_session_, &SessionMultiProxy::update_use_pfs, use_pfs);
|
send_closure_later(dcs_[i - 1].download_small_session_, &SessionMultiProxy::update_use_pfs, use_pfs);
|
||||||
|
@ -61,19 +61,23 @@ void SessionMultiProxy::update_main_flag(bool is_main) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SessionMultiProxy::destroy_auth_key() {
|
void SessionMultiProxy::destroy_auth_key() {
|
||||||
need_destroy_auth_key_ = true;
|
update_options(1, false, true);
|
||||||
send_closure(sessions_[0].proxy, &SessionProxy::destroy_auth_key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionMultiProxy::update_session_count(int32 session_count) {
|
void SessionMultiProxy::update_session_count(int32 session_count) {
|
||||||
update_options(session_count, use_pfs_);
|
update_options(session_count, use_pfs_, need_destroy_auth_key_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionMultiProxy::update_use_pfs(bool use_pfs) {
|
void SessionMultiProxy::update_use_pfs(bool use_pfs) {
|
||||||
update_options(session_count_, use_pfs);
|
update_options(session_count_, use_pfs, need_destroy_auth_key_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SessionMultiProxy::update_options(int32 session_count, bool use_pfs, bool need_destroy_auth_key) {
|
||||||
|
if (need_destroy_auth_key_) {
|
||||||
|
LOG(INFO) << "Ignore session option changes while destroying auth key";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionMultiProxy::update_options(int32 session_count, bool use_pfs) {
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
if (session_count != session_count_) {
|
if (session_count != session_count_) {
|
||||||
@ -96,6 +100,12 @@ void SessionMultiProxy::update_options(int32 session_count, bool use_pfs) {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (need_destroy_auth_key) {
|
||||||
|
need_destroy_auth_key_ = need_destroy_auth_key;
|
||||||
|
LOG(WARNING) << "Destroy auth key in " << get_name();
|
||||||
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class SessionMultiProxy final : public Actor {
|
|||||||
|
|
||||||
void update_session_count(int32 session_count);
|
void update_session_count(int32 session_count);
|
||||||
void update_use_pfs(bool use_pfs);
|
void update_use_pfs(bool use_pfs);
|
||||||
void update_options(int32 session_count, bool use_pfs);
|
void update_options(int32 session_count, bool use_pfs, bool need_destroy_auth_key);
|
||||||
void update_mtproto_header();
|
void update_mtproto_header();
|
||||||
|
|
||||||
void destroy_auth_key();
|
void destroy_auth_key();
|
||||||
|
@ -172,16 +172,6 @@ void SessionProxy::update_main_flag(bool is_main) {
|
|||||||
open_session();
|
open_session();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionProxy::destroy_auth_key() {
|
|
||||||
if (need_destroy_auth_key_) {
|
|
||||||
LOG(INFO) << "Ignore reduntant destroy_auth_key";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
need_destroy_auth_key_ = true;
|
|
||||||
close_session();
|
|
||||||
open_session();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionProxy::on_failed() {
|
void SessionProxy::on_failed() {
|
||||||
if (session_generation_ != get_link_token()) {
|
if (session_generation_ != get_link_token()) {
|
||||||
return;
|
return;
|
||||||
|
@ -42,8 +42,6 @@ class SessionProxy final : public Actor {
|
|||||||
|
|
||||||
void update_mtproto_header();
|
void update_mtproto_header();
|
||||||
|
|
||||||
void destroy_auth_key();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unique_ptr<Callback> callback_;
|
unique_ptr<Callback> callback_;
|
||||||
std::shared_ptr<AuthDataShared> auth_data_;
|
std::shared_ptr<AuthDataShared> auth_data_;
|
||||||
|
Loading…
Reference in New Issue
Block a user