Don't try to init proxies if they have never been added.

This commit is contained in:
levlam 2023-10-12 23:41:46 +03:00
parent 93ddc9c3db
commit eed6e0bba6
2 changed files with 14 additions and 5 deletions

View File

@ -1090,6 +1090,19 @@ void ConnectionCreator::start_up() {
on_dc_options(std::move(dc_options)); on_dc_options(std::move(dc_options));
} }
if (G()->td_db()->get_binlog_pmc()->get("proxy_max_id") != "2" ||
!G()->td_db()->get_binlog_pmc()->get(get_proxy_database_key(1)).empty()) {
// don't need to init proxies if they have never been added
init_proxies();
}
ref_cnt_guard_ = create_reference(-1);
is_inited_ = true;
loop();
}
void ConnectionCreator::init_proxies() {
auto proxy_info = G()->td_db()->get_binlog_pmc()->prefix_get("proxy"); auto proxy_info = G()->td_db()->get_binlog_pmc()->prefix_get("proxy");
auto it = proxy_info.find("_max_id"); auto it = proxy_info.find("_max_id");
if (it != proxy_info.end()) { if (it != proxy_info.end()) {
@ -1145,11 +1158,6 @@ void ConnectionCreator::start_up() {
on_proxy_changed(true); on_proxy_changed(true);
} }
ref_cnt_guard_ = create_reference(-1);
is_inited_ = true;
loop();
} }
void ConnectionCreator::hangup_shared() { void ConnectionCreator::hangup_shared() {

View File

@ -205,6 +205,7 @@ class ConnectionCreator final : public NetQueryCallback {
void hangup() final; void hangup() final;
void loop() final; void loop() final;
void init_proxies();
void save_dc_options(); void save_dc_options();
Result<SocketFd> do_request_connection(DcId dc_id, bool allow_media_only); Result<SocketFd> do_request_connection(DcId dc_id, bool allow_media_only);
Result<std::pair<unique_ptr<mtproto::RawConnection>, bool>> do_request_raw_connection(DcId dc_id, Result<std::pair<unique_ptr<mtproto::RawConnection>, bool>> do_request_raw_connection(DcId dc_id,