Notify sessions about mtproto header updates.

GitOrigin-RevId: 35ee6055c65c7656726a20672fa600823a13ac5f
This commit is contained in:
levlam 2018-05-10 21:02:24 +03:00
parent 47d5082253
commit 1492467ab8
5 changed files with 28 additions and 2 deletions

View File

@ -229,8 +229,13 @@ void ConnectionCreator::set_proxy_impl(Proxy proxy, bool from_db) {
return;
}
if (proxy_.type() == Proxy::Type::Mtproto || proxy.type() == Proxy::Type::Mtproto) {
G()->mtproto_header().set_proxy(proxy);
G()->net_query_dispatcher().update_mtproto_header();
}
proxy_ = std::move(proxy);
G()->mtproto_header().set_proxy(proxy_);
send_closure(G()->state_manager(), &StateManager::on_proxy, have_proxy);
if (!from_db) {

View File

@ -221,6 +221,19 @@ void NetQueryDispatcher::update_use_pfs() {
}
}
}
void NetQueryDispatcher::update_mtproto_header() {
std::lock_guard<std::mutex> guard(main_dc_id_mutex_);
for (size_t i = 1; i < MAX_DC_COUNT; i++) {
if (is_dc_inited(narrow_cast<int32>(i))) {
send_closure_later(dcs_[i - 1].main_session_, &SessionMultiProxy::update_mtproto_header);
send_closure_later(dcs_[i - 1].upload_session_, &SessionMultiProxy::update_mtproto_header);
send_closure_later(dcs_[i - 1].download_session_, &SessionMultiProxy::update_mtproto_header);
send_closure_later(dcs_[i - 1].download_small_session_, &SessionMultiProxy::update_mtproto_header);
}
}
}
void NetQueryDispatcher::update_valid_dc(DcId dc_id) {
wait_dc_init(dc_id, true);
}

View File

@ -45,8 +45,11 @@ class NetQueryDispatcher {
void update_session_count();
void update_use_pfs();
void update_mtproto_header();
void update_valid_dc(DcId dc_id);
DcId main_dc_id() {
DcId main_dc_id() const {
return DcId::internal(main_dc_id_.load());
}

View File

@ -87,6 +87,10 @@ void SessionMultiProxy::update_options(int32 session_count, bool use_pfs) {
}
}
void SessionMultiProxy::update_mtproto_header() {
init();
}
void SessionMultiProxy::start_up() {
init();
}

View File

@ -32,6 +32,7 @@ class SessionMultiProxy : public Actor {
void update_session_count(int32 session_count);
void update_use_pfs(bool use_pfs);
void update_options(int32 session_count, bool use_pfs);
void update_mtproto_header();
private:
size_t pos_ = 0;