diff --git a/td/telegram/net/SessionMultiProxy.cpp b/td/telegram/net/SessionMultiProxy.cpp index 7c181804f..be0c9a1b9 100644 --- a/td/telegram/net/SessionMultiProxy.cpp +++ b/td/telegram/net/SessionMultiProxy.cpp @@ -44,12 +44,12 @@ void SessionMultiProxy::send(NetQueryPtr query) { pos = query->session_rand() % sessions_.size(); } else { pos = std::min_element(sessions_.begin(), sessions_.end(), - [](const auto &a, const auto &b) { return a.queries_count < b.queries_count; }) - + [](const auto &a, const auto &b) { return a.query_count < b.query_count; }) - sessions_.begin(); } } // query->debug(PSTRING() << get_name() << ": send to proxy #" << pos); - sessions_[pos].queries_count++; + sessions_[pos].query_count++; send_closure(sessions_[pos].proxy, &SessionProxy::send, std::move(query)); } @@ -152,8 +152,10 @@ void SessionMultiProxy::on_query_finished(uint32 generation, int session_id) { if (generation != sessions_generation_) { return; } - sessions_.at(session_id).queries_count--; - CHECK(sessions_.at(session_id).queries_count >= 0); + CHECK(static_cast(session_id) < sessions_.size()); + auto &query_count = sessions_[session_id].query_count; + CHECK(query_count > 0); + query_count--; } } // namespace td diff --git a/td/telegram/net/SessionMultiProxy.h b/td/telegram/net/SessionMultiProxy.h index 673476375..cea1bfad2 100644 --- a/td/telegram/net/SessionMultiProxy.h +++ b/td/telegram/net/SessionMultiProxy.h @@ -48,7 +48,7 @@ class SessionMultiProxy final : public Actor { bool need_destroy_auth_key_ = false; struct SessionInfo { ActorOwn proxy; - int queries_count{0}; + int query_count{0}; }; uint32 sessions_generation_{0}; std::vector sessions_;