dnsdist: Prevent race while creating new TCP worker threads #4764

Merged
merged 2 commits into from Dec 14, 2016

Projects

None yet

1 participant

@rgacogne
Member

Short description

We try very hard to avoid using locks, but we need to prevent two threads inserting into the TCP workers vector concurrently. While this can't happen at runtime since the healthcheck thread is the only one calling g_tcpclientthreads->addTCPClientThread(), this might happen at startup time because we start the TCP acceptor threads one after another and they all call it once. This might result, for example, in one vector entry being overwritten and another one remaining value-initialized to zero.

Reported and very kindly investigated by @paddg (thanks!).

Checklist

I have:

@rgacogne rgacogne dnsdist: Prevent race while creating new TCP worker threads
We try very hard to avoid using locks, but we need to prevent two
threads inserting into the TCP workers vector concurrently. While
this can't happen at runtime since the healthcheck thread is the
only one calling `g_tcpclientthreads->addTCPClientThread()`, this
might happen at startup time because we start the TCP acceptor
threads one after another and they all call it once.
This might result, for example, in one vector entry being overwritten
and another one remaining value-initialized to zero.
ded1985
@rgacogne rgacogne added this to the dnsdist-1.1.0 milestone Dec 13, 2016
@rgacogne rgacogne merged commit 3a9f699 into PowerDNS:master Dec 14, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@rgacogne rgacogne deleted the rgacogne:dnsdist-tcp-workers-vect-race branch Dec 14, 2016
@rgacogne rgacogne added a commit to rgacogne/pdns that referenced this pull request Dec 14, 2016
@rgacogne rgacogne dnsdist: Add #4764 and #4765 to the beta2 ChangeLog 0189084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment