Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
e11a59e3
Commit
e11a59e3
authored
7 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
cta/CTA#130 Helgrind gets spurious when using `std::mutex` in the catalogue.
Removed last use of std::mutex from the rdbms library
parent
1a6c0f34
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rdbms/ConnPool.cpp
+9
-8
9 additions, 8 deletions
rdbms/ConnPool.cpp
rdbms/ConnPool.hpp
+7
-7
7 additions, 7 deletions
rdbms/ConnPool.hpp
with
16 additions
and
15 deletions
rdbms/ConnPool.cpp
+
9
−
8
View file @
e11a59e3
...
...
@@ -17,6 +17,7 @@
*/
#include
"common/exception/Exception.hpp"
#include
"common/threading/MutexLocker.hpp"
#include
"rdbms/ConnPool.hpp"
#include
<iostream>
...
...
@@ -56,10 +57,10 @@ void ConnPool::createConns(const uint64_t nbConns) {
// getConn
//------------------------------------------------------------------------------
PooledConn
ConnPool
::
getConn
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_connsMutex
);
threading
::
MutexLocker
lock
er
(
m_connsMutex
);
while
(
m_conns
.
size
()
==
0
&&
m_nbConnsOnLoan
==
m_maxNbConns
)
{
m_connsCv
.
wait
(
lock
);
m_connsCv
.
wait
(
lock
er
);
}
if
(
m_conns
.
size
()
==
0
)
{
...
...
@@ -99,7 +100,7 @@ void ConnPool::returnConn(std::unique_ptr<Conn> conn) {
// connection, if there is one, has been lost. Delete all the connections
// currently in the pool because their underlying TCP/IP connections may
// also have been lost.
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_connsMutex
);
threading
::
MutexLocker
lock
er
(
m_connsMutex
);
while
(
!
m_conns
.
empty
())
{
m_conns
.
pop_front
();
}
...
...
@@ -107,17 +108,17 @@ void ConnPool::returnConn(std::unique_ptr<Conn> conn) {
throw
exception
::
Exception
(
"Would have reached -1 connections on loan"
);
}
m_nbConnsOnLoan
--
;
m_connsCv
.
notify_one
();
m_connsCv
.
signal
();
return
;
}
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_connsMutex
);
threading
::
MutexLocker
lock
er
(
m_connsMutex
);
if
(
0
==
m_nbConnsOnLoan
)
{
throw
exception
::
Exception
(
"Would have reached -1 connections on loan"
);
}
m_nbConnsOnLoan
--
;
m_conns
.
push_back
(
std
::
move
(
conn
));
m_connsCv
.
notify_one
();
m_connsCv
.
signal
();
// Else the connection is closed
}
else
{
...
...
@@ -126,7 +127,7 @@ void ConnPool::returnConn(std::unique_ptr<Conn> conn) {
// connection, if there is one, has been lost. Delete all the connections
// currently in the pool because their underlying TCP/IP connections may
// also have been lost.
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_connsMutex
);
threading
::
MutexLocker
lock
er
(
m_connsMutex
);
while
(
!
m_conns
.
empty
())
{
m_conns
.
pop_front
();
}
...
...
@@ -134,7 +135,7 @@ void ConnPool::returnConn(std::unique_ptr<Conn> conn) {
throw
exception
::
Exception
(
"Would have reached -1 connections on loan"
);
}
m_nbConnsOnLoan
--
;
m_connsCv
.
notify_one
();
m_connsCv
.
signal
();
}
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
ex
.
getMessage
().
str
());
...
...
This diff is collapsed.
Click to expand it.
rdbms/ConnPool.hpp
+
7
−
7
View file @
e11a59e3
...
...
@@ -18,14 +18,14 @@
#pragma once
#include
"Conn.hpp"
#include
"ConnFactory.hpp"
#include
"PooledConn.hpp"
#include
"common/threading/CondVar.hpp"
#include
"common/threading/Mutex.hpp"
#include
"rdbms/Conn.hpp"
#include
"rdbms/ConnFactory.hpp"
#include
"rdbms/PooledConn.hpp"
#include
<condition_variable>
#include
<list>
#include
<memory>
#include
<mutex>
namespace
cta
{
namespace
rdbms
{
...
...
@@ -91,13 +91,13 @@ private:
/**
* Mutex used to serialize access to the database connections within the pool.
*/
std
::
m
utex
m_connsMutex
;
threading
::
M
utex
m_connsMutex
;
/**
* Condition variable used by threads returning connections to the pool to
* notify threads waiting for connections.
*/
std
::
c
ond
ition_variable
m_connsCv
;
threading
::
C
ond
Var
m_connsCv
;
/**
* The database connections within the pool.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment