BUG/MINOR: stats: Make stat_l variable used to dump a stat line thread local
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 6 Jan 2021 06:41:56 +0000 (07:41 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 6 Jan 2021 16:23:13 +0000 (17:23 +0100)
commite1c074eae946e73d5cd08a1a2c4173e318297a9b
tree187e04bd88c6a02a85221056c7b39e11615585c2
parent3326c6afe779bc8da84dd22fbb1ba84564a7b884
BUG/MINOR: stats: Make stat_l variable used to dump a stat line thread local

Since ee63d4bd6 ("MEDIUM: stats: integrate static proxies stats in new
stats"), all dumped stats for a given domain, the default ones and the
modules ones, are merged in a signle array to dump them in a generic way.
For this purpose, the stat_l global variable is allocated at startup to
store a line of stats before the dump, i.e. all stats of an entity
(frontend, backend, listener, server or dns nameserver). But this variable
is not thread safe.  If stats are retrieved concurrently by several clients
on different threads, the same variable is used. This leads to corrupted
stats output.

To fix the bug, the stat_l variable is now thread local.

This patch should probably solve issues #972 and #992. It must be backported
to 2.3.

(cherry picked from commit de79cd28ec9e1facc5f2da02cd95dda82ac6fe58)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/stats.c