diff --git a/src/iocore/net/SSLCertLookup.cc b/src/iocore/net/SSLCertLookup.cc index 4b51a21579e..f7f0699786b 100644 --- a/src/iocore/net/SSLCertLookup.cc +++ b/src/iocore/net/SSLCertLookup.cc @@ -34,6 +34,7 @@ #include "P_SSLUtils.h" #include +#include #include #include #include @@ -234,24 +235,24 @@ ssl_create_ticket_keyblock(const char *ticket_key_path) SSLCertContext::SSLCertContext(SSLCertContext const &other) { + std::shared_lock lock(other.ctx_mutex); opt = other.opt; userconfig = other.userconfig; keyblock = other.keyblock; ctx_type = other.ctx_type; - std::shared_lock lock(other.ctx_mutex); - ctx = other.ctx; + ctx = other.ctx; } SSLCertContext & SSLCertContext::operator=(SSLCertContext const &other) { if (&other != this) { + std::scoped_lock lock(this->ctx_mutex, other.ctx_mutex); this->opt = other.opt; this->userconfig = other.userconfig; this->keyblock = other.keyblock; this->ctx_type = other.ctx_type; - std::shared_lock lock(other.ctx_mutex); - this->ctx = other.ctx; + this->ctx = other.ctx; } return *this; }