diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-03-24 17:31:42 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-03-24 17:31:42 +0000 |
commit | 83200b6de517b3634769090fd04523ab25a8942b (patch) | |
tree | 8f380f4bdddd77c48167bc3eee0679d1107f0328 /cpp/src | |
parent | Fixed bug 916 (diff) | |
download | ice-83200b6de517b3634769090fd04523ab25a8942b.tar.bz2 ice-83200b6de517b3634769090fd04523ab25a8942b.tar.xz ice-83200b6de517b3634769090fd04523ab25a8942b.zip |
Fixed bug 885 and 920
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.cpp | 32 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.h | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 4 |
3 files changed, 32 insertions, 5 deletions
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp index bf82a95a24c..ae35ff622b6 100644 --- a/cpp/src/IceGrid/DescriptorHelper.cpp +++ b/cpp/src/IceGrid/DescriptorHelper.cpp @@ -353,8 +353,13 @@ Resolver::asInt(const string& value, const string& name) const string v = operator()(value, name); if(!v.empty()) { + string::size_type beg = v.find_first_not_of(' '); + string::size_type end = v.find_last_not_of(' '); + v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1); + int val; - if(!(istringstream(v) >> val)) + istringstream is(v); + if(!(is >> val) || !is.eof()) { DeploymentException ex; ex.reason = "invalid value `" + value + "' for `" + name + "' in " + _context + ": not an integer"; @@ -364,6 +369,29 @@ Resolver::asInt(const string& value, const string& name) const return v; } +string +Resolver::asFloat(const string& value, const string& name) const +{ + string v = operator()(value, name); + if(!v.empty()) + { + string::size_type beg = v.find_first_not_of(' '); + string::size_type end = v.find_last_not_of(' '); + v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1); + + float val; + istringstream is(v); + if(!(is >> val) || !is.eof()) + { + DeploymentException ex; + ex.reason = "invalid value `" + value + "' for `" + name + "' in " + _context + ": not a float"; + throw ex; + } + cerr << v << " " << val << endl; + } + return v; +} + void Resolver::setReserved(const string& name, const string& value) { @@ -1488,7 +1516,7 @@ NodeHelper::instantiate(const Resolver& resolve) const { NodeDescriptor desc; desc.variables = _definition.variables; - desc.loadFactor = resolve(_definition.loadFactor, "load factor"); + desc.loadFactor = resolve.asFloat(_definition.loadFactor, "load factor"); desc.description = resolve(_definition.description, "description"); ServerInstanceHelperDict::const_iterator r; for(r = _serverInstances.begin(); r != _serverInstances.end(); ++r) diff --git a/cpp/src/IceGrid/DescriptorHelper.h b/cpp/src/IceGrid/DescriptorHelper.h index fd6c74838c9..413b81b0832 100644 --- a/cpp/src/IceGrid/DescriptorHelper.h +++ b/cpp/src/IceGrid/DescriptorHelper.h @@ -28,6 +28,7 @@ public: std::string operator()(const std::string&, const std::string& = std::string(), bool = true, bool = true) const; std::string asInt(const std::string&, const std::string& = std::string()) const; + std::string asFloat(const std::string&, const std::string& = std::string()) const; void setReserved(const std::string&, const std::string&); void setContext(const std::string&); diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 2df872dd65a..ffc96e2e6fa 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -965,8 +965,6 @@ ServerI::checkDestroyed() void ServerI::disableOnFailure() { - assert(_state != Deactivating); // This must be called before switching to the Deactivating state. - // // If the server is already disabled, nothing to do. // @@ -980,7 +978,7 @@ ServerI::disableOnFailure() // is always and the server wasn't active at the time of the // failure we disable the server. // - if(_disableOnFailure != 0 || _activation == Always && _state != Active) + if(_disableOnFailure != 0 || _activation == Always && (_state == Activating || _state == WaitForActivation)) { _previousActivation = _activation; _activation = Disabled; |