]> git.ipfire.org Git - thirdparty/haproxy.git/commit
CLEANUP: peers: factor out the key len calculation in received updates
authorWilly Tarreau <w@1wt.eu>
Tue, 29 Nov 2022 16:43:10 +0000 (17:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 29 Nov 2022 17:06:42 +0000 (18:06 +0100)
commitb12be7c1bb7703830b3dff221f770d7c4df3c5a9
tree474467aeaf02c4f49db0b04656ca224a0c07b94f
parentd5cae6a0c70bb9b31c3973676eba3359f765592d
CLEANUP: peers: factor out the key len calculation in received updates

In peer_treat_updatemsg(), the lower layers of the stick-table code are
reimplemented, and the key length is never really known for an entry
being processed, it depends on the type being parsed and the moment
where it's done. This makes it quite difficult to stuff some shard
number calculation there.

This patch adds a keylen local variable that is always set to the length
of the current key depending on its type. It takes this opportunity for
reducing redudant expressions involving this length and always using the
new variable instead, limiting the risk of errors. Arguably that code
would have been way simpler by creating a dummy stktable_key and passing
it to stksess_new() as done anywhere else, but let's not change all that
a few days before the release.
src/peers.c