From da9afda7e622daf5605ce59703705d58796fed6d Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 8 Nov 2023 11:26:37 +0300 Subject: [PATCH] Fix SessionMultiProxy::update_options. --- td/telegram/net/SessionMultiProxy.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/td/telegram/net/SessionMultiProxy.cpp b/td/telegram/net/SessionMultiProxy.cpp index f8e6d768c..0251e472e 100644 --- a/td/telegram/net/SessionMultiProxy.cpp +++ b/td/telegram/net/SessionMultiProxy.cpp @@ -78,18 +78,13 @@ void SessionMultiProxy::update_options(int32 session_count, bool use_pfs, bool n return; } - bool changed = false; + bool is_changed = false; + session_count = clamp(session_count, 1, 100); if (session_count != session_count_) { session_count_ = session_count; - if (session_count_ <= 0) { - session_count_ = 1; - } - if (session_count_ > 100) { - session_count_ = 100; - } LOG(INFO) << "Update session_count to " << session_count_; - changed = true; + is_changed = true; } if (use_pfs != use_pfs_) { @@ -97,16 +92,17 @@ void SessionMultiProxy::update_options(int32 session_count, bool use_pfs, bool n use_pfs_ = use_pfs; if (old_pfs_flag != get_pfs_flag()) { LOG(INFO) << "Update use_pfs to " << use_pfs_; - changed = true; + is_changed = true; } } if (need_destroy_auth_key) { need_destroy_auth_key_ = need_destroy_auth_key; + is_changed = true; LOG(WARNING) << "Destroy auth key"; } - if (changed) { + if (is_changed) { init(); } }