]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MAJOR: thread: Be sure to request a sync between threads only once at a time
authorChristopher Faulet <cfaulet@haproxy.com>
Sat, 2 Dec 2017 08:53:24 +0000 (09:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 2 Dec 2017 13:31:01 +0000 (14:31 +0100)
commit81991d32853ed4c7ccf80871b0f73d3a2f3cc1d5
treee46c904f194b5f1b72d4fc2b0d133a0ce95f04bd
parent829aa24459c633896113e9e438c43b9dfcdfce27
BUG/MAJOR: thread: Be sure to request a sync between threads only once at a time

The first thread requesting a synchronization is responsible to write in the
"sync" pipe to notify all others. But we must write only once in the pipe
between two synchronizations to have exactly one character in the pipe. It is
important because we only read 1 character in return when the last thread exits
from the sync-point.

Here there is a bug. If two threads request a synchronization, only the first
writes in the pipe. But, if the same thread requests several times a
synchronization before entering in the sync-point (because, for instance, it
detects many servers down), it writes as many as characters in the pipe. And
only one of them will be read. Repeating this bug many times will block HAProxy
on the write because the pipe is full.

To fix the bug, we just check if the current thread has already requested a
synchronization before trying to notify all others.

The patch must be backported in 1.8
src/hathreads.c