From: Remi Gacogne Date: Fri, 30 Apr 2021 13:50:09 +0000 (+0200) Subject: dnsdist: Convert GnuTLSTicketsKey to SharedLockGuarded X-Git-Tag: dnsdist-1.7.0-alpha1~62^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4172902ee2b990e700a03a3ea25fc68c88696dac;p=thirdparty%2Fpdns.git dnsdist: Convert GnuTLSTicketsKey to SharedLockGuarded --- diff --git a/pdns/tcpiohandler.cc b/pdns/tcpiohandler.cc index d4f7bc36e6..40137041b0 100644 --- a/pdns/tcpiohandler.cc +++ b/pdns/tcpiohandler.cc @@ -1155,8 +1155,7 @@ public: std::shared_ptr ticketsKey; { - ReadLock rl(&d_lock); - ticketsKey = d_ticketsKey; + ticketsKey = *(d_ticketsKey.read_lock()); } return std::make_unique(socket, timeout, d_creds.get(), d_priorityCache, ticketsKey, d_enableTickets); @@ -1176,8 +1175,7 @@ public: auto newKey = std::make_shared(); { - WriteLock wl(&d_lock); - d_ticketsKey = newKey; + *(d_ticketsKey.lock()) = newKey; } if (d_ticketsKeyRotationDelay > 0) { @@ -1193,8 +1191,7 @@ public: auto newKey = std::make_shared(file); { - WriteLock wl(&d_lock); - d_ticketsKey = newKey; + *(d_ticketsKey.lock()) = newKey; } if (d_ticketsKeyRotationDelay > 0) { @@ -1204,15 +1201,13 @@ public: size_t getTicketsKeysCount() override { - ReadLock rl(&d_lock); - return d_ticketsKey != nullptr ? 1 : 0; + return *(d_ticketsKey.read_lock()) != nullptr ? 1 : 0; } private: std::unique_ptr d_creds; gnutls_priority_t d_priorityCache{nullptr}; - std::shared_ptr d_ticketsKey{nullptr}; - ReadWriteLock d_lock; + SharedLockGuarded> d_ticketsKey{nullptr}; bool d_enableTickets{true}; bool d_validateCerts{true}; };