forked from cms-sw/cmsdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
castor-2.1.13.6-fix-pthreads-darwin.patch
88 lines (84 loc) · 3.53 KB
/
castor-2.1.13.6-fix-pthreads-darwin.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
diff --git a/castor/common/CastorConfiguration.cpp b/castor/common/CastorConfiguration.cpp
index 6706580..d9968aa 100644
--- a/castor/common/CastorConfiguration.cpp
+++ b/castor/common/CastorConfiguration.cpp
@@ -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);
@@ -80,6 +80,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
//------------------------------------------------------------------------------
castor::common::CastorConfiguration::~CastorConfiguration() {
@@ -88,6 +102,23 @@ castor::common::CastorConfiguration::~CastorConfiguration() {
}
//------------------------------------------------------------------------------
+// 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
//------------------------------------------------------------------------------
const std::string&
diff --git a/castor/common/CastorConfiguration.hpp b/castor/common/CastorConfiguration.hpp
index 6ea9fbe..be9229c 100644
--- a/castor/common/CastorConfiguration.hpp
+++ b/castor/common/CastorConfiguration.hpp
@@ -67,11 +67,25 @@ namespace castor {
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
* @param key the key of the entry