MINOR: pattern: store a generation number in the reference patterns
authorWilly Tarreau <w@1wt.eu>
Wed, 28 Oct 2020 10:43:49 +0000 (11:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Nov 2020 18:27:09 +0000 (19:27 +0100)
commit29947745b5dd1a0a45c8153f5c5b92b87cd27b74
tree3368fd00ec3f1e60b08489dc0feaec781b14b71f
parent1fd52f70e59ca87307d1599d63efae041e8f27f1
MINOR: pattern: store a generation number in the reference patterns

Right now it's not possible to perform a safe reload because we don't
know what patterns were recently added or were already present. This
patch adds a generation counter to the reference patterns so that it
is possible to know what generation of the reference they were loaded
with. A reference now has two generations, the current one, used for
all additions, and the next one, allocated to those wishing to update
the contents. The generation wraps at 2^32 so comparisons must be made
relative to the current position.

The idea will be that upon full reload, the caller will first get a new
generation ID, will insert all new patterns using it, will then switch
the current ID to the new one, and will delete all entries older than
the current ID. This has the benefit of supporting chunked updates that
remain consistent and that won't block the whole process for ages like
pat_ref_reload() currently does.
include/haproxy/pattern-t.h
src/pattern.c