From 241ec94c60b4c2169938d7214d5ee7ac11f86576 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Sat, 26 Oct 2019 18:47:49 +0200 Subject: [PATCH] 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. --- pdns/dnsdistdist/doh.cc | 3 +-- pdns/doh.hh | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) 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; } } -- 2.40.0