Skip to content
Snippets Groups Projects
Commit c879d911 authored by Steven Murray's avatar Steven Murray
Browse files

cta/CTA#130 Helgrind gets spurious when using `std::mutex` in the catalogue.

With respect to the rdbms::SqliteConn class. Replaced
std::mutex and std::lock_guard with their helgrind friendly
drop in replacements threading::Mutex and
threading::MutexLocker.
parent 6e37f631
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
#include "common/exception/Exception.hpp"
#include "common/make_unique.hpp"
#include "common/threading/MutexLocker.hpp"
#include "rdbms/SqliteConn.hpp"
#include "rdbms/SqliteStmt.hpp"
......@@ -72,7 +73,7 @@ SqliteConn::~SqliteConn() throw() {
// close
//------------------------------------------------------------------------------
void SqliteConn::close() {
std::lock_guard<std::mutex> lock(m_mutex);
threading::MutexLocker locker(m_mutex);
if(nullptr != m_sqliteConn) {
sqlite3_close(m_sqliteConn);
......@@ -85,7 +86,7 @@ void SqliteConn::close() {
//------------------------------------------------------------------------------
std::unique_ptr<Stmt> SqliteConn::createStmt(const std::string &sql, const Stmt::AutocommitMode autocommitMode) {
try {
std::lock_guard<std::mutex> lock(m_mutex);
threading::MutexLocker locker(m_mutex);
if(nullptr == m_sqliteConn) {
throw exception::Exception("Connection is closed");
......@@ -102,7 +103,7 @@ std::unique_ptr<Stmt> SqliteConn::createStmt(const std::string &sql, const Stmt:
//------------------------------------------------------------------------------
void SqliteConn::commit() {
try {
std::lock_guard<std::mutex> lock(m_mutex);
threading::MutexLocker locker(m_mutex);
if(nullptr == m_sqliteConn) {
throw exception::Exception("Connection is closed");
......@@ -131,7 +132,7 @@ void SqliteConn::commit() {
//------------------------------------------------------------------------------
void SqliteConn::rollback() {
try {
std::lock_guard<std::mutex> lock(m_mutex);
threading::MutexLocker locker(m_mutex);
if(nullptr == m_sqliteConn) {
throw exception::Exception("Connection is closed");
......
......@@ -18,9 +18,9 @@
#pragma once
#include "Conn.hpp"
#include "common/threading/Mutex.hpp"
#include "rdbms/Conn.hpp"
#include <mutex>
#include <sqlite3.h>
namespace cta {
......@@ -110,7 +110,7 @@ private:
/**
* Mutex used to serialize access to the database connection.
*/
std::mutex m_mutex;
threading::Mutex m_mutex;
/**
* The database connection.
......
......@@ -18,6 +18,7 @@
#include "common/exception/Exception.hpp"
#include "common/make_unique.hpp"
#include "common/threading/MutexLocker.hpp"
#include "rdbms/Sqlite.hpp"
#include "rdbms/SqliteConn.hpp"
#include "rdbms/SqliteRset.hpp"
......@@ -215,7 +216,7 @@ std::unique_ptr<Rset> SqliteStmt::executeQuery() {
// executeNonQuery
//------------------------------------------------------------------------------
void SqliteStmt::executeNonQuery() {
std::lock_guard<std::mutex> connLock(m_conn.m_mutex);
threading::MutexLocker connLocker(m_conn.m_mutex);
const int stepRc = sqlite3_step(m_stmt);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment