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
405f5c4e
Commit
405f5c4e
authored
12 years ago
by
Giuseppe Lo Presti
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug #99123: Unsafe usage of locks in CastorConfiguration.
Patch provided by David Abdurachmanov (CMSSW).
parent
a7192b4f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
castor/common/CastorConfiguration.cpp
+32
-1
32 additions, 1 deletion
castor/common/CastorConfiguration.cpp
castor/common/CastorConfiguration.hpp
+14
-0
14 additions, 0 deletions
castor/common/CastorConfiguration.hpp
with
46 additions
and
1 deletion
castor/common/CastorConfiguration.cpp
+
32
−
1
View file @
405f5c4e
...
...
@@ -53,7 +53,7 @@ castor::common::CastorConfiguration::getConfig(std::string fileName)
// do we have this configuration already in cache ?
if
(
s_castorConfigs
.
end
()
==
s_castorConfigs
.
find
(
fileName
))
{
// no such configuration. Create it
s_castorConfigs
[
fileName
]
=
CastorConfiguration
(
fileName
);
s_castorConfigs
.
insert
(
std
::
make_pair
(
fileName
,
CastorConfiguration
(
fileName
)
))
;
}
// we can now release the lock. Concurrent read only access is ok.
pthread_mutex_unlock
(
&
s_globalConfigLock
);
...
...
@@ -79,6 +79,20 @@ castor::common::CastorConfiguration::CastorConfiguration(std::string fileName)
}
}
//------------------------------------------------------------------------------
// copy constructor
//------------------------------------------------------------------------------
castor
::
common
::
CastorConfiguration
::
CastorConfiguration
(
const
CastorConfiguration
&
other
)
throw
(
castor
::
exception
::
Exception
)
:
m_fileName
(
other
.
m_fileName
),
m_lastUpdateTime
(
other
.
m_lastUpdateTime
),
m_config
(
other
.
m_config
)
{
// create a new internal r/w lock
int
rc
=
pthread_rwlock_init
(
&
m_lock
,
NULL
);
if
(
0
!=
rc
)
{
castor
::
exception
::
Exception
e
(
rc
);
throw
e
;
}
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
...
...
@@ -87,6 +101,23 @@ castor::common::CastorConfiguration::~CastorConfiguration() {
pthread_rwlock_destroy
(
&
m_lock
);
}
//------------------------------------------------------------------------------
// assignment operator
//------------------------------------------------------------------------------
castor
::
common
::
CastorConfiguration
&
castor
::
common
::
CastorConfiguration
::
operator
=
(
const
castor
::
common
::
CastorConfiguration
&
other
)
throw
(
castor
::
exception
::
Exception
)
{
m_fileName
=
other
.
m_fileName
;
m_lastUpdateTime
=
other
.
m_lastUpdateTime
;
m_config
=
other
.
m_config
;
// create a new internal r/w lock
int
rc
=
pthread_rwlock_init
(
&
m_lock
,
NULL
);
if
(
0
!=
rc
)
{
castor
::
exception
::
Exception
e
(
rc
);
throw
e
;
}
return
*
this
;
}
//------------------------------------------------------------------------------
// getConfEnt
//------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
castor/common/CastorConfiguration.hpp
+
14
−
0
View file @
405f5c4e
...
...
@@ -66,11 +66,25 @@ namespace castor {
CastorConfiguration
(
std
::
string
fileName
=
"/etc/castor/castor.conf"
)
throw
(
castor
::
exception
::
Exception
);
/**
* copy constructor
* @param other instance of CastorConfiguration class
*/
CastorConfiguration
(
const
CastorConfiguration
&
other
)
throw
(
castor
::
exception
::
Exception
);
/**
* destrcutor
*/
virtual
~
CastorConfiguration
();
/**
* assignment operator
* @param other instance of CastorConfiguration class
*/
CastorConfiguration
&
operator
=
(
const
CastorConfiguration
&
other
)
throw
(
castor
::
exception
::
Exception
);
/**
* retrieves a configuration entry
* @param category the category of the entry
...
...
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