diff options
author | Marc Laukien <marc@zeroc.com> | 2002-02-14 04:16:37 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-02-14 04:16:37 +0000 |
commit | 0f6931918a5fe32cd90fb9f599682838f48cb716 (patch) | |
tree | 3201933dcf9691bffd803ed0116895dbf5645d8a /cpp/src | |
parent | Removed file that shouldn't be present until after merging FreezeXML (diff) | |
download | ice-0f6931918a5fe32cd90fb9f599682838f48cb716.tar.bz2 ice-0f6931918a5fe32cd90fb9f599682838f48cb716.tar.xz ice-0f6931918a5fe32cd90fb9f599682838f48cb716.zip |
fixes, simplifications
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/DBI.cpp | 40 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Glacier/GlacierI.cpp | 21 | ||||
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 28 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.h | 3 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 12 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.cpp | 17 | ||||
-rw-r--r-- | cpp/src/IceStorm/Flusher.cpp | 17 | ||||
-rw-r--r-- | cpp/src/IceStorm/Server.cpp | 7 |
13 files changed, 45 insertions, 126 deletions
diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp index 6ca18413f97..254291b451d 100644 --- a/cpp/src/Freeze/DBI.cpp +++ b/cpp/src/Freeze/DBI.cpp @@ -69,15 +69,7 @@ Freeze::DBEnvironmentI::DBEnvironmentI(const CommunicatorPtr& communicator, cons _name(name) { _errorPrefix = "Freeze::DBEnvironment(\"" + _name + "\"): "; - - PropertiesPtr properties = _communicator->getProperties(); - string value; - - value = properties->getProperty("Freeze.Trace.DB"); - if (!value.empty()) - { - _trace = atoi(value.c_str()); - } + _trace = atoi(_communicator->getProperties()->getProperty("Freeze.Trace.DB").c_str()); checkBerkeleyDBReturn(db_env_create(&_dbEnv, 0), _errorPrefix, "db_env_create"); @@ -247,15 +239,7 @@ Freeze::DBTransactionI::DBTransactionI(const CommunicatorPtr& communicator, ::DB _name(name) { _errorPrefix = "Freeze::DBTransaction(\"" + _name + "\"): "; - - PropertiesPtr properties = _communicator->getProperties(); - string value; - - value = properties->getProperty("Freeze.Trace.DB"); - if (!value.empty()) - { - _trace = atoi(value.c_str()); - } + _trace = atoi(_communicator->getProperties()->getProperty("Freeze.Trace.DB").c_str()); if (_trace >= 2) { @@ -331,16 +315,8 @@ DBCursorI::DBCursorI(const ::Ice::CommunicatorPtr& communicator, const std::stri _name(name), _cursor(cursor) { - PropertiesPtr properties = _communicator->getProperties(); - string value; - - value = properties->getProperty("Freeze.Trace.DB"); - if (!value.empty()) - { - _trace = atoi(value.c_str()); - } - _errorPrefix = "Freeze::DBCursor(\"" + _name += "\"): "; + _trace = atoi(_communicator->getProperties()->getProperty("Freeze.Trace.DB").c_str()); if (_trace >= 1) { @@ -583,15 +559,7 @@ Freeze::DBI::DBI(const CommunicatorPtr& communicator, const DBEnvironmentIPtr& d _name(name) { _errorPrefix = "Freeze::DB(\"" + _name + "\"): "; - - PropertiesPtr properties = _communicator->getProperties(); - string value; - - value = properties->getProperty("Freeze.Trace.DB"); - if (!value.empty()) - { - _trace = atoi(value.c_str()); - } + _trace = atoi(_communicator->getProperties()->getProperty("Freeze.Trace.DB").c_str()); if (_trace >= 1) { diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index 1b242c86e93..3eaa91de3d9 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -23,14 +23,7 @@ Freeze::EvictorI::EvictorI(const DBPtr& db, EvictorPersistenceMode persistenceMo _persistenceMode(persistenceMode), _trace(0) { - PropertiesPtr properties = _db->getCommunicator()->getProperties(); - string value; - - value = properties->getProperty("Freeze.Trace.Evictor"); - if (!value.empty()) - { - _trace = atoi(value.c_str()); - } + _trace = atoi(_db->getCommunicator()->getProperties()->getProperty("Freeze.Trace.Evictor").c_str()); } Freeze::EvictorI::~EvictorI() diff --git a/cpp/src/Glacier/GlacierI.cpp b/cpp/src/Glacier/GlacierI.cpp index bd4d76da1d3..31402be91f3 100644 --- a/cpp/src/Glacier/GlacierI.cpp +++ b/cpp/src/Glacier/GlacierI.cpp @@ -53,12 +53,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, con // // Start a router // - string path = _properties->getProperty("Glacier.Starter.RouterPath"); - if (path.empty()) - { - path = "glacier"; - } - + string path = _properties->getPropertyWithDefault("Glacier.Starter.RouterPath", "glacier"); string uuid = IceUtil::generateUUID(); pid_t pid; int fds[2]; @@ -200,18 +195,10 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, con FD_ZERO(&fdSet); FD_SET(fds[0], &fdSet); struct timeval tv; - string timeout = _properties->getProperty("Glacier.Starter.StartupTimeout"); - if (timeout.empty()) - { - tv.tv_sec = 10; // 10 seconds default. - } - else + tv.tv_sec = atoi(_properties->getPropertyWithDefault("Glacier.Starter.StartupTimeout", "10").c_str()); + if (tv.tv_sec < 1) { - tv.tv_sec = atoi(timeout.c_str()); - if (tv.tv_sec < 1) - { - tv.tv_sec = 1; // One second is minimum. - } + tv.tv_sec = 1; // One second is minimum. } tv.tv_usec = 0; int ret = ::select(fds[0] + 1, &fdSet, 0, 0, &tv); diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index ff590515c48..a04a525872e 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -573,7 +573,7 @@ IceInternal::Connection::Connection(const InstancePtr& instance, _responseCount(0), _state(StateHolding) { - _warn = atoi(_instance->properties()->getProperty("Ice.ConnectionWarnings").c_str()) > 0 ? true : false; + _warn = atoi(_instance->properties()->getProperty("Ice.ConnectionWarnings").c_str()) > 0; } IceInternal::Connection::~Connection() diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 8724ac12b7f..337812908bd 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -390,7 +390,7 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance _adapter(adapter), _state(StateHolding) { - _warn = atoi(_instance->properties()->getProperty("Ice.ConnectionWarnings").c_str()) > 0 ? true : false; + _warn = atoi(_instance->properties()->getProperty("Ice.ConnectionWarnings").c_str()) > 0; try { diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 0944c67443f..8ae3d115247 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -181,11 +181,8 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope if (++_globalStateCounter == 1) // Only on first call { - string value; - // Must be done before "Ice.Daemon" is checked - value = _properties->getProperty("Ice.PrintProcessId"); - if (atoi(value.c_str()) >= 1) + if (atoi(_properties->getProperty("Ice.PrintProcessId").c_str()) > 0) { #ifdef WIN32 cout << _getpid() << endl; @@ -195,14 +192,10 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope } #ifndef WIN32 - value = _properties->getProperty("Ice.Daemon"); - if (atoi(value.c_str()) >= 1) + if (atoi(_properties->getProperty("Ice.Daemon").c_str()) > 0) { - value = _properties->getProperty("Ice.DaemonNoClose"); - int noclose = atoi(value.c_str()); - - value = _properties->getProperty("Ice.DaemonNoChdir"); - int nochdir = atoi(value.c_str()); + int noclose = atoi(_properties->getProperty("Ice.DaemonNoClose").c_str()); + int nochdir = atoi(_properties->getProperty("Ice.DaemonNoChdir").c_str()); if (daemon(nochdir, noclose) == -1) { @@ -216,8 +209,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope #endif #ifndef WIN32 - value = _properties->getProperty("Ice.UseSyslog"); - if (atoi(value.c_str()) >= 1) + if (atoi(_properties->getProperty("Ice.UseSyslog").c_str()) > 0) { _identForOpenlog = _properties->getProperty("Ice.ProgramName"); if (_identForOpenlog.empty()) @@ -265,10 +257,8 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope try { __setNoDelete(true); - string value; #ifndef WIN32 - value = _properties->getProperty("Ice.UseSyslog"); - if (atoi(value.c_str()) >= 1) + if (atoi(_properties->getProperty("Ice.UseSyslog").c_str()) > 0) { _logger = new SysLoggerI; } @@ -293,10 +283,10 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope _routerManager = new RouterManager; _referenceFactory = new ReferenceFactory(this); _proxyFactory = new ProxyFactory(this); - value = _properties->getProperty("Ice.DefaultRouter"); - if (!value.empty()) + string router = _properties->getProperty("Ice.DefaultRouter"); + if (!router.empty()) { - _referenceFactory->setDefaultRouter(RouterPrx::uncheckedCast(_proxyFactory->stringToProxy(value))); + _referenceFactory->setDefaultRouter(RouterPrx::uncheckedCast(_proxyFactory->stringToProxy(router))); } _outgoingConnectionFactory = new OutgoingConnectionFactory(this); _servantFactoryManager = new ObjectFactoryManager(); diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 320ba1dd783..841a8a9f8cf 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -433,8 +433,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const string& n } */ - string value = _instance->properties()->getProperty("Ice.PrintAdapterReady"); - if (atoi(value.c_str()) >= 1) + if (atoi(_instance->properties()->getProperty("Ice.PrintAdapterReady").c_str()) > 0) { cout << _name << " ready" << endl; } diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 5ac7d055580..11a0d1aa7ca 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -21,6 +21,8 @@ std::set<string> Ice::PropertiesI::_argumentPrefixes; string Ice::PropertiesI::getProperty(const string& key) { + IceUtil::Mutex::Lock sync(*this); + map<string, string>::const_iterator p = _properties.find(key); if (p != _properties.end()) { @@ -35,6 +37,8 @@ Ice::PropertiesI::getProperty(const string& key) string Ice::PropertiesI::getPropertyWithDefault(const string& key, const string& value) { + IceUtil::Mutex::Lock sync(*this); + map<string, string>::const_iterator p = _properties.find(key); if (p != _properties.end()) { @@ -49,12 +53,16 @@ Ice::PropertiesI::getPropertyWithDefault(const string& key, const string& value) void Ice::PropertiesI::setProperty(const string& key, const string& value) { + IceUtil::Mutex::Lock sync(*this); + _properties[key] = value; } StringSeq Ice::PropertiesI::getCommandLineOptions() { + IceUtil::Mutex::Lock sync(*this); + StringSeq result; result.reserve(_properties.size()); map<string, string>::const_iterator p; @@ -68,6 +76,8 @@ Ice::PropertiesI::getCommandLineOptions() PropertiesPtr Ice::PropertiesI::clone() { + IceUtil::Mutex::Lock sync(*this); + int dummy = 0; PropertiesI* p = new PropertiesI(dummy, 0); p->_properties = _properties; diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h index 9d228382cbd..d134544016e 100644 --- a/cpp/src/Ice/PropertiesI.h +++ b/cpp/src/Ice/PropertiesI.h @@ -11,13 +11,14 @@ #ifndef ICE_PROPERTIES_I_H #define ICE_PROPERTIES_I_H +#include <IceUtil/Mutex.h> #include <Ice/Properties.h> #include <set> namespace Ice { -class ICE_API PropertiesI : public Properties +class ICE_API PropertiesI : public Properties, public IceUtil::Mutex { public: diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 14124f4e1a5..4a09bf995c0 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -154,16 +154,10 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance) : _minFd = _fdIntrRead; _timeout = atoi(_instance->properties()->getProperty("Ice.ServerIdleTime").c_str()); - - _threadNum = 10; - string value = _instance->properties()->getProperty("Ice.ThreadPool.Size"); - if (!value.empty()) + _threadNum = atoi(_instance->properties()->getPropertyWithDefault("Ice.ThreadPool.Size", "10").c_str()); + if (_threadNum < 1) { - _threadNum = atoi(value.c_str()); - if (_threadNum < 1) - { - _threadNum = 1; - } + _threadNum = 1; } try diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp index 5c8829cc05a..b8a97961828 100644 --- a/cpp/src/IcePack/Forward.cpp +++ b/cpp/src/IcePack/Forward.cpp @@ -24,21 +24,10 @@ IcePack::Forward::Forward(const CommunicatorPtr& communicator, const AdminPtr& a _activator = new Activator(_communicator); _activator->start(); - PropertiesPtr properties = communicator->getProperties(); - string value; - - value = properties->getProperty("IcePack.Activator.WaitTime"); - if (value.length()) - { - _waitTime = atoi(value.c_str()); - if (_waitTime < 0) - { - _waitTime = 0; - } - } - else + _waitTime = atoi(properties->getPropertyWithDefault("IcePack.Activator.WaitTime", "10").c_str()); + if (_waitTime < 0) { - _waitTime = 10; + _waitTime = 0; } #endif } diff --git a/cpp/src/IceStorm/Flusher.cpp b/cpp/src/IceStorm/Flusher.cpp index 60eaf240ee7..913612843c2 100644 --- a/cpp/src/IceStorm/Flusher.cpp +++ b/cpp/src/IceStorm/Flusher.cpp @@ -37,20 +37,11 @@ public: _traceLevels(traceLevels), _destroy(false) { - Ice::PropertiesPtr properties = communicator->getProperties(); - string value; - value = properties->getProperty("IceStorm.Flush.Timeout"); - if (!value.empty()) + _flushTime = atoi(communicator->getProperties()-> + getPropertyWithDefault("IceStorm.Flush.Timeout", "1000").c_str()); + if (_flushTime < 100) { - _flushTime = atoi(value.c_str()); - if (_flushTime < 100) - { - _flushTime = 100; // Minimum of 100 ms - } - } - else - { - _flushTime = 1000; // Default of 1 second + _flushTime = 100; // Minimum of 100 ms } } diff --git a/cpp/src/IceStorm/Server.cpp b/cpp/src/IceStorm/Server.cpp index b0c25829a26..92d4d015acb 100644 --- a/cpp/src/IceStorm/Server.cpp +++ b/cpp/src/IceStorm/Server.cpp @@ -49,11 +49,8 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - string dbEnvName = defaultProperties->getProperty("IceStorm.DBEnvName"); - if (dbEnvName.empty()) - { - dbEnvName = "db"; - } + string dbEnvName = defaultProperties->getPropertyWithDefault("IceStorm.DBEnvName", "db"); + Server app(dbEnvName); return app.main(argc, argv); } |