]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MAJOR: ebtree/scope: fix lookup of next node in scope-aware trees
authorWilly Tarreau <w@1wt.eu>
Mon, 13 Nov 2017 17:55:44 +0000 (18:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Nov 2017 18:34:09 +0000 (19:34 +0100)
commit52743305861bf8da7220d402c1bb0d9bba4db06b
tree75b796820ecd2e8ef710d9c65220a72c76943eb0
parentd19ec7d5021ec2a813ec9eed245f20bfade22e97
BUG/MAJOR: ebtree/scope: fix lookup of next node in scope-aware trees

The eb32sc_walk_down_left() function needs to be able to go up when
it doesn't find a matching entry because this situation may always
happen, especially when fixing two constraints (scope + value). It
also happens after certain removal situations where some bits remain
on some intermediary nodes in the tree.

In addition, the algorithm for deciding to take the right branch is
wrong as it would take it if the current node shows a scope that
doesn't matchthe required one.

The current code is flakey in that it returns NULL when the bottom
has been reached and it's up to the caller to visit other nodes above.
In addition to being complex it's not reliable, and it was noticed a
few times that some tasks could remain lying in the tree after heavy
insertion/removals under multi-threaded workloads.

Now instead we make eb32sc_walk_down_left() visit the leftmost branch
that matches the scope, and automatically go up to visit the closest
matching right branch. This effectively does the same operations as a
next() operation but in reverse order (down then up instead of up then
down).

The eb32sc_next() function now becomes very simple again and matches
the original one, and the initial issues cannot be met anymore.

No backport is needed, this is purely 1.8-specific.
ebtree/eb32sctree.h