From: Remi Gacogne Date: Sat, 26 Oct 2019 16:47:49 +0000 (+0200) Subject: dnsdist: Fix a race condition in the DOHUnit reference counter X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=241ec94c60b4c2169938d7214d5ee7ac11f86576;p=pdns dnsdist: Fix a race condition in the DOHUnit reference counter It was based on the reference counter used for the DOHAcceptContext where thread safety was never an issue because those objects are not shared between threads, but DOHUnit are. --- diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc index 923f9eb81..9b29e650b 100644 --- a/pdns/dnsdistdist/doh.cc +++ b/pdns/dnsdistdist/doh.cc @@ -75,8 +75,7 @@ public: void release() { - --d_refcnt; - if (d_refcnt == 0) { + if (--d_refcnt == 0) { SSL_CTX_free(d_h2o_accept_ctx.ssl_ctx); d_h2o_accept_ctx.ssl_ctx = nullptr; delete this; diff --git a/pdns/doh.hh b/pdns/doh.hh index 53cfbcd20..ba0499f7e 100644 --- a/pdns/doh.hh +++ b/pdns/doh.hh @@ -151,8 +151,7 @@ struct DOHUnit void release() { - --d_refcnt; - if (d_refcnt == 0) { + if (--d_refcnt == 0) { delete this; } }