MXS-2067: Replace most SPINLOCKs

Replaced SPINLOCK with std::mutex where possible, leaving out the more
complex cases. The big offenders remaining are the binlogrouter and the
gateway.cc OpenSSL locks.
This commit is contained in:
Markus Mäkelä
2018-09-26 09:35:33 +03:00
parent 50451166bb
commit ab4f870927
17 changed files with 76 additions and 215 deletions

View File

@ -47,7 +47,6 @@ SchemaRouter::SchemaRouter(SERVICE* service, SConfig config)
, m_config(config)
, m_service(service)
{
spinlock_init(&m_lock);
}
SchemaRouter::~SchemaRouter()

View File

@ -14,6 +14,7 @@
#include "schemarouter.hh"
#include <mutex>
#include <set>
#include <string>
@ -51,7 +52,7 @@ private:
SConfig m_config; /*< expanded config info from SERVICE */
ShardManager m_shard_manager; /*< Shard maps hashed by user name */
SERVICE* m_service; /*< Pointer to service */
SPINLOCK m_lock; /*< Lock for the instance data */
std::mutex m_lock; /*< Lock for the instance data */
Stats m_stats; /*< Statistics for this router */
};
}

View File

@ -111,7 +111,8 @@ void SchemaRouterSession::close()
}
}
spinlock_acquire(&m_router->m_lock);
std::lock_guard<std::mutex> guard(m_router->m_lock);
if (m_router->m_stats.longest_sescmd < m_stats.longest_sescmd)
{
m_router->m_stats.longest_sescmd = m_stats.longest_sescmd;
@ -129,8 +130,6 @@ void SchemaRouterSession::close()
m_router->m_stats.ses_average =
(ses_time + ((m_router->m_stats.sessions - 1) * m_router->m_stats.ses_average))
/ (m_router->m_stats.sessions);
spinlock_release(&m_router->m_lock);
}
}