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-Tag: rec-4.3.0-alpha2~7^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=241ec94c60b4c2169938d7214d5ee7ac11f86576;p=thirdparty%2Fpdns.git 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 923f9eb816..9b29e650b8 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 53cfbcd206..ba0499f7e0 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; } }