- Timestamp:
- 11/10/09 00:02:12 (4 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 773ad32
- Parents:
- 7f9c823
- Location:
- service
- Files:
-
- 2 edited
-
NSClient++.cpp (modified) (14 diffs)
-
NSClient++.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
service/NSClient++.cpp
r7f9c823 r6672c56 1013 1013 std::wstring moduleList = _T(""); 1014 1014 { 1015 ReadLock readLock(&m_mutexRW, true, 10000);1016 if (!readLock. IsLocked()) {1015 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::seconds(5)); 1016 if (!readLock.owns_lock()) { 1017 1017 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1018 1018 return -1; … … 1059 1059 */ 1060 1060 void NSClientT::addPlugins(const std::list<std::wstring> plugins) { 1061 ReadLock readLock(&m_mutexRW, true, 10000);1062 if (!readLock. IsLocked()) {1061 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::seconds(10)); 1062 if (!readLock.owns_lock()) { 1063 1063 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1064 1064 return; … … 1074 1074 void NSClientT::unloadPlugins(bool unloadLoggers) { 1075 1075 { 1076 WriteLock writeLock(&m_mutexRW, true, 10000);1077 if (!writeLock. IsLocked()) {1076 boost::unique_lock<boost::shared_mutex> writeLock(m_mutexRW, boost::get_system_time() + boost::posix_time::seconds(10)); 1077 if (!writeLock.owns_lock()) { 1078 1078 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1079 1079 return; … … 1084 1084 } 1085 1085 { 1086 ReadLock readLock(&m_mutexRW, true, 10000);1087 if (!readLock. IsLocked()) {1086 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::milliseconds(5000)); 1087 if (!readLock.owns_lock()) { 1088 1088 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1089 1089 return; … … 1108 1108 } 1109 1109 { 1110 WriteLock writeLock(&m_mutexRW, true, 10000);1111 if (!writeLock. IsLocked()) {1110 boost::unique_lock<boost::shared_mutex> writeLock(m_mutexRW, boost::get_system_time() + boost::posix_time::seconds(10)); 1111 if (!writeLock.owns_lock()) { 1112 1112 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1113 1113 return; … … 1134 1134 bool hasBroken = false; 1135 1135 { 1136 ReadLock readLock(&m_mutexRW, true, 10000);1137 if (!readLock. IsLocked()) {1136 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::milliseconds(5000)); 1137 if (!readLock.owns_lock()) { 1138 1138 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1139 1139 return; … … 1185 1185 plugin->load_dll(); 1186 1186 { 1187 WriteLock writeLock(&m_mutexRW, true, 10000);1188 if (!writeLock. IsLocked()) {1187 boost::unique_lock<boost::shared_mutex> writeLock(m_mutexRW, boost::get_system_time() + boost::posix_time::seconds(10)); 1188 if (!writeLock.owns_lock()) { 1189 1189 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1190 1190 return plugin; … … 1202 1202 1203 1203 std::wstring NSClientT::describeCommand(std::wstring command) { 1204 ReadLock readLock(&m_mutexRWcmdDescriptions, true, 5000);1205 if (!readLock. IsLocked()) {1204 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRWcmdDescriptions, boost::get_system_time() + boost::posix_time::seconds(5)); 1205 if (!readLock.owns_lock()) { 1206 1206 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex when trying to get command list.")); 1207 1207 return _T("Failed to get mutex when describing command: ") + command; … … 1214 1214 std::list<std::wstring> NSClientT::getAllCommandNames() { 1215 1215 std::list<std::wstring> lst; 1216 ReadLock readLock(&m_mutexRWcmdDescriptions, true, 5000);1217 if (!readLock. IsLocked()) {1216 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRWcmdDescriptions, boost::get_system_time() + boost::posix_time::seconds(5)); 1217 if (!readLock.owns_lock()) { 1218 1218 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex when trying to get command list.")); 1219 1219 return lst; … … 1225 1225 } 1226 1226 void NSClientT::registerCommand(std::wstring cmd, std::wstring desc) { 1227 WriteLock writeLock(&m_mutexRWcmdDescriptions, true, 10000);1228 if (!writeLock. IsLocked()) {1227 boost::unique_lock<boost::shared_mutex> writeLock(m_mutexRWcmdDescriptions, boost::get_system_time() + boost::posix_time::seconds(10)); 1228 if (!writeLock.owns_lock()) { 1229 1229 LOG_ERROR_STD(_T("FATAL ERROR: Failed to describe command:") + cmd); 1230 1230 return; … … 1313 1313 } 1314 1314 } else { 1315 ReadLock readLock(&m_mutexRW, true, 5000);1316 if (!readLock. IsLocked()) {1315 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::milliseconds(5000)); 1316 if (!readLock.owns_lock()) { 1317 1317 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1318 1318 return NSCAPI::returnUNKNOWN; … … 1352 1352 1353 1353 void NSClientT::listPlugins() { 1354 ReadLock readLock(&m_mutexRW, true, 10000);1355 if (!readLock. IsLocked()) {1354 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::milliseconds(5000)); 1355 if (!readLock.owns_lock()) { 1356 1356 LOG_ERROR(_T("FATAL ERROR: Could not get read-mutex.")); 1357 1357 return; … … 1418 1418 file_stl = file_stl.substr(pos); 1419 1419 { 1420 ReadLock readLock(&m_mutexRW, true, 5000);1421 if (!readLock. IsLocked()) {1420 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::milliseconds(5000)); 1421 if (!readLock.owns_lock()) { 1422 1422 log_broken_message(_T("Message was lost as the (mutexRW) core was locked: ") + message); 1423 1423 return; 1424 1424 } 1425 boost::unique_lock<boost::timed_mutex> lock(messageMutex, boost::get_system_time() + boost::posix_time:: milliseconds(5000));1425 boost::unique_lock<boost::timed_mutex> lock(messageMutex, boost::get_system_time() + boost::posix_time::seconds(5)); 1426 1426 if (!lock.owns_lock()) { 1427 1427 log_broken_message(_T("Message was lost as the core was locked: ") + message); … … 1488 1488 } 1489 1489 std::wstring NSClientT::getBasePath(void) { 1490 boost::unique_lock<boost::timed_mutex> lock(internalVariables, boost::get_system_time() + boost::posix_time:: milliseconds(5000));1490 boost::unique_lock<boost::timed_mutex> lock(internalVariables, boost::get_system_time() + boost::posix_time::seconds(5)); 1491 1491 if (!lock.owns_lock()) { 1492 1492 LOG_ERROR(_T("FATAL ERROR: Could not get mutex.")); -
service/NSClient++.h
r7f9c823 r6672c56 24 24 #include <service/system_service.hpp> 25 25 #include "NSCPlugin.h" 26 #include <Mutex.h>26 //#include <Mutex.h> 27 27 #include <NSCAPI.h> 28 #include <MutexRW.h>28 //#include <MutexRW.h> 29 29 #include <map> 30 30 #include <com_helpers.hpp> … … 32 32 #include <boost/thread/thread.hpp> 33 33 #include <boost/thread/locks.hpp> 34 #include <boost/thread/shared_mutex.hpp> 35 34 36 35 37 /** … … 101 103 boost::timed_mutex internalVariables; 102 104 boost::timed_mutex messageMutex; 103 MutexRWm_mutexRW;104 MutexRWm_mutexRWcmdDescriptions;105 boost::shared_mutex m_mutexRW; 106 boost::shared_mutex m_mutexRWcmdDescriptions; 105 107 cmdMap cmdDescriptions_; 106 108 typedef enum log_status {log_unknown, log_looking, log_debug, log_nodebug };
Note: See TracChangeset
for help on using the changeset viewer.








