]> granicus.if.org Git - pdns/commitdiff
dnsdist: Fix a race condition in the DOHUnit reference counter
authorRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 26 Oct 2019 16:47:49 +0000 (18:47 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 26 Oct 2019 16:47:49 +0000 (18:47 +0200)
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
pdns/doh.hh

index 923f9eb816c07d65d7c1c41499bb203fd46f5ab6..9b29e650b810bc5179e35964bbfa475ea1cdc483 100644 (file)
@@ -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;
index 53cfbcd206630491bd74c43212e4c55cce68781d..ba0499f7e048ef08b12b47ef33a1db04481c31d2 100644 (file)
@@ -151,8 +151,7 @@ struct DOHUnit
 
   void release()
   {
-    --d_refcnt;
-    if (d_refcnt == 0) {
+    if (--d_refcnt == 0) {
       delete this;
     }
   }