1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-07-29 03:41:11 +03:00

Reset values properly in HTTPPriorityQueue::clear()

Summary: Fixing bug where `HTTPPriorityQueue::clear()` doesn't properly reset `roundRobinElements_` and `lowestRoundRobin_`.

Reviewed By: hanidamlaj

Differential Revision: D76171861

fbshipit-source-id: fc408471be75e42abda934f79493bb801c2258dc
This commit is contained in:
Joanna Jo
2025-06-09 16:14:22 -07:00
committed by Facebook GitHub Bot
parent be23e87323
commit d00df1332b
2 changed files with 12 additions and 0 deletions

View File

@ -167,6 +167,8 @@ void HTTPPriorityQueue::clear() {
for (auto& rr : roundRobins_) { for (auto& rr : roundRobins_) {
rr.clear(); rr.clear();
} }
roundRobinElements_ = 0;
lowestRoundRobin_ = roundRobins_.size();
} }
const HTTPPriorityQueue::Element* FOLLY_NULLABLE const HTTPPriorityQueue::Element* FOLLY_NULLABLE

View File

@ -21,6 +21,16 @@ class HTTPPriorityQueueTest : public testing::Test {
}; };
TEST_F(HTTPPriorityQueueTest, EmptyQueue) { TEST_F(HTTPPriorityQueueTest, EmptyQueue) {
queue_.clear();
EXPECT_TRUE(queue_.empty());
}
TEST_F(HTTPPriorityQueueTest, IncrementalEmptyQueue) {
auto id = Identifier::fromStreamID(1);
auto priority = HTTPPriorityQueue::Priority(0, true);
queue_.insertOrUpdate(id, priority);
EXPECT_FALSE(queue_.empty());
queue_.clear();
EXPECT_TRUE(queue_.empty()); EXPECT_TRUE(queue_.empty());
} }