From 335ac34fade5256e556713cfcf0a137d7c1ed7c3 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 17 Aug 2020 17:35:34 +0300 Subject: [PATCH] Fix Session::PriorityQueue. GitOrigin-RevId: adfab64ecf7eae2c73759c7e6f927b88f4fd2236 --- td/telegram/net/Session.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 87dc5cec0..d811f3f05 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -118,14 +118,16 @@ class GenAuthKeyActor : public Actor { } // namespace detail void Session::PriorityQueue::push(NetQueryPtr query) { - queries_[query->priority()].push(std::move(query)); + auto priority = query->priority(); + queries_[priority].push(std::move(query)); } NetQueryPtr Session::PriorityQueue::pop() { - auto it = prev(end(queries_)); + auto it = queries_.rbegin(); + CHECK(it != queries_.rend()); auto res = it->second.pop(); if (it->second.empty()) { - queries_.erase(it); + queries_.erase(it->first); } return res; }