Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/ts/PriorityQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ PriorityQueue<T, Comp>::erase(PriorityQueueEntry<T> *entry)
return;
}

// If the entry doesn't belong to this queue just return.
if (entry != _v[entry->index]) {
ink_assert(!_v.in(entry));
return;
}

ink_release_assert(entry->index < _v.length());
const uint32_t original_index = entry->index;
if (original_index != (_v.length() - 1)) {
Expand Down
30 changes: 30 additions & 0 deletions lib/ts/test_PriorityQueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,33 @@ REGRESSION_TEST(PriorityQueue_pop_and_erase)(RegressionTest *t, int /* atype ATS
delete entry_y;
delete entry_z;
}

REGRESSION_TEST(PriorityQueue_pop_and_erase_2)(RegressionTest *t, int /* atype ATS_UNUSED */, int *pstatus)
{
TestBox box(t, pstatus);
box = REGRESSION_TEST_PASSED;

PQ *pq1 = new PQ();

N *x = new N(20, "X");
N *y = new N(30, "Y");

Entry *X = new Entry(x);
Entry *Y = new Entry(y);

box.check(X->index == 0 && Y->index == 0, "X and Y index should be 0");

pq1->push(X);

pq1->erase(Y);

box.check(pq1->top() == X, "X should be in queue");

delete x;
delete y;

delete X;
delete Y;

delete pq1;
}
8 changes: 8 additions & 0 deletions proxy/http2/Http2DependencyTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,20 @@ Http2DependencyTree<T>::add(uint32_t parent_id, uint32_t id, uint32_t weight, bo

if (exclusive) {
while (Node *child = parent->children.pop()) {
if (child->queued) {
parent->queue->erase(child->entry);
node->queue->push(child->entry);
}
node->children.push(child);
child->parent = node;
}
}

parent->children.push(node);
if (!node->queue->empty()) {
parent->queue->push(node->entry);
node->queued = true;
}

++_node_count;
return node;
Expand Down
32 changes: 32 additions & 0 deletions proxy/http2/test_Http2DependencyTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,38 @@ REGRESSION_TEST(Http2DependencyTree_remove_2)(RegressionTest *t, int /* atype AT
delete tree;
}

/**
* Exclusive Dependency Creation
*
* A A
* / \ => |
* B C D
* / \
* B C
*/
REGRESSION_TEST(Http2DependencyTree_exclusive_node)(RegressionTest *t, int /* atype ATS_UNUSED */, int *pstatus)
{
TestBox box(t, pstatus);
box = REGRESSION_TEST_PASSED;

Tree *tree = new Tree(100);
string a("A"), b("B"), c("C"), d("D");

Tree::Node *B = tree->add(0, 1, 0, false, &b);
tree->add(0, 3, 0, false, &c);

tree->activate(B);
// Add node with exclusive flag
tree->add(0, 5, 0, true, &d);

tree->deactivate(B, 0);
tree->remove(B);

box.check(tree->top() == NULL, "Tree top should be NULL");

delete tree;
}

REGRESSION_TEST(Http2DependencyTree_max_depth)(RegressionTest *t, int /* atype ATS_UNUSED */, int *pstatus)
{
TestBox box(t, pstatus);
Expand Down