refactor: use std::scoped_lock inplace of std::lock_guard

This commit is contained in:
sithlord48
2025-06-15 20:15:07 -04:00
committed by Nick Bolton
parent 5fd4d93f7f
commit c15214aee7
16 changed files with 92 additions and 92 deletions

View File

@ -230,7 +230,7 @@ TCPSocket::EJobResult SecureSocket::doWrite()
int SecureSocket::secureRead(void *buffer, int size, int &read)
{
std::lock_guard ssl_lock{ssl_mutex_};
std::scoped_lock ssl_lock{ssl_mutex_};
if (m_ssl->m_ssl != nullptr) {
LOG((CLOG_DEBUG2 "reading secure socket"));
@ -257,7 +257,7 @@ int SecureSocket::secureRead(void *buffer, int size, int &read)
int SecureSocket::secureWrite(const void *buffer, int size, int &wrote)
{
std::lock_guard ssl_lock{ssl_mutex_};
std::scoped_lock ssl_lock{ssl_mutex_};
if (m_ssl->m_ssl != nullptr) {
LOG((CLOG_DEBUG2 "writing secure socket: %p", this));
@ -290,7 +290,7 @@ bool SecureSocket::isSecureReady() const
void SecureSocket::initSsl(bool server)
{
std::lock_guard ssl_lock{ssl_mutex_};
std::scoped_lock ssl_lock{ssl_mutex_};
m_ssl = new Ssl();
m_ssl->m_context = nullptr;
@ -301,7 +301,7 @@ void SecureSocket::initSsl(bool server)
bool SecureSocket::loadCertificates(const std::string &filename)
{
std::lock_guard ssl_lock{ssl_mutex_};
std::scoped_lock ssl_lock{ssl_mutex_};
if (filename.empty()) {
SslLogger::logError("tls certificate is not specified");
@ -392,7 +392,7 @@ void SecureSocket::createSSL()
void SecureSocket::freeSSL()
{
std::lock_guard ssl_lock{ssl_mutex_};
std::scoped_lock ssl_lock{ssl_mutex_};
isFatal(true);
// take socket from multiplexer ASAP otherwise the race condition
@ -417,7 +417,7 @@ void SecureSocket::freeSSL()
int SecureSocket::secureAccept(int socket)
{
std::lock_guard ssl_lock{ssl_mutex_};
std::scoped_lock ssl_lock{ssl_mutex_};
createSSL();
@ -479,7 +479,7 @@ int SecureSocket::secureConnect(int socket)
return -1;
}
std::lock_guard ssl_lock{ssl_mutex_};
std::scoped_lock ssl_lock{ssl_mutex_};
createSSL();