BUG/MEDIUM: checks: Make sure we set the task affinity just before connecting.
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 29 Nov 2019 15:18:51 +0000 (16:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 Dec 2019 09:03:43 +0000 (10:03 +0100)
commite77b108cde2c9b47f4e7c6f932310e1a5ac674d7
tree2d8d98710af0554b70ff6715268672ef95f81b26
parent279698ebdef2c00e7a01544af0321438b69ea7d1
BUG/MEDIUM: checks: Make sure we set the task affinity just before connecting.

In process_chk_conn(), make sure we set the task affinity to the current
thread as soon as we're attempting a connection (and reset the affinity to
"any thread" if we detect a failure).
We used to only set the task affinity if connect_conn_chk() returned
SF_ERR_NONE, however for TCP checks, SF_ERR_UP is returned, so for those
checks, the task could still run on any thread, and this could lead to a
race condition where the connection runs on one thread, while the task runs
on another one, which could create random memory corruption and/or crashes.
This may fix github issue #369.

This should be backported to 2.1, 2.0 and 1.9.

(cherry picked from commit aebeff74fc7eaef12728b1fc15b2d42d93a7767a)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/checks.c