]> git.ipfire.org Git - thirdparty/pdns.git/commit
dnsdist: Fix a hang when removing a server with more than one socket 9900/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 24 Dec 2020 10:38:26 +0000 (11:38 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 24 Dec 2020 10:38:26 +0000 (11:38 +0100)
commit0ac246e2e848bf244506b7d6a7031fb7d0de335b
tree6cb241de6951749f60f0db9c57582dabceebcf7d
parent3ee80dc3cd2a52f41890f731987c0871f8516340
dnsdist: Fix a hang when removing a server with more than one socket

There was a lock starvation issue when removing a server with more
than one socket in use (`sockets` greater than 1 on the corresponding
`newServer` directive), because the mutex protecting the sockets array
would never be released long enough by the responder thread to allow
the thread stopping the server to acquire it.
This commit fixes that by marking the server as stopped right away,
before acquiring the lock, and also making sure that the responder
thread is woken up regularly (every second, even without any query
to process) and that it checks whether the server has been stopped
just after that.

The issue was introduced in be55a20ce9bb7140071279d70bcb460f1f2b7b7d,
and backported to 1.5.1 in f0d48318cce0dd80ae73c529362bdb2921d8c5c9.
pdns/dnsdist.cc
pdns/dnsdistdist/dnsdist-backend.cc