Fix Session::PriorityQueue.

GitOrigin-RevId: adfab64ecf7eae2c73759c7e6f927b88f4fd2236
This commit is contained in:
levlam 2020-08-17 17:35:34 +03:00
parent 641485502e
commit 335ac34fad

View File

@ -118,14 +118,16 @@ class GenAuthKeyActor : public Actor {
} // namespace detail } // namespace detail
void Session::PriorityQueue::push(NetQueryPtr query) { 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() { NetQueryPtr Session::PriorityQueue::pop() {
auto it = prev(end(queries_)); auto it = queries_.rbegin();
CHECK(it != queries_.rend());
auto res = it->second.pop(); auto res = it->second.pop();
if (it->second.empty()) { if (it->second.empty()) {
queries_.erase(it); queries_.erase(it->first);
} }
return res; return res;
} }