diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-01-24 09:16:49 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-01-24 09:16:49 +0000 |
commit | f5af565c4380aef921fc884dfd0bd9d18dad9b79 (patch) | |
tree | 25ca74a6a36768923021de673945d5efe52f02b2 /cpp/src | |
parent | http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=783 (diff) | |
download | ice-f5af565c4380aef921fc884dfd0bd9d18dad9b79.tar.bz2 ice-f5af565c4380aef921fc884dfd0bd9d18dad9b79.tar.xz ice-f5af565c4380aef921fc884dfd0bd9d18dad9b79.zip |
Added stress test to activation test suite, fixed another race condition
that could occur if server activation failed.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/Activator.cpp | 14 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 86 |
2 files changed, 43 insertions, 57 deletions
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index 0dc94443d97..09045b8f0f8 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -370,8 +370,11 @@ Activator::activate(const string& name, string ext = path.size() <= 4 || path[path.size() - 4] != '.' ? ".exe" : ""; if(SearchPath(NULL, path.c_str(), ext.c_str(), _MAX_PATH, absbuf, &filePart) == 0) { - Error out(_traceLevels->logger); - out << "cannot convert `" << path << "' into an absolute path"; + if(_traceLevels->activator > 0) + { + Trace out(_traceLevels->logger, _traceLevels->activatorCat); + out << "cannot convert `" << path << "' into an absolute path"; + } throw string("The server executable path `" + path + "' can't be converted into an absolute path."); } path = absbuf; @@ -390,8 +393,11 @@ Activator::activate(const string& name, char absbuf[_MAX_PATH]; if(_fullpath(absbuf, pwd.c_str(), _MAX_PATH) == NULL) { - Error out(_traceLevels->logger); - out << "cannot convert `" << pwd << "' into an absolute path"; + if(_traceLevels->activator > 0) + { + Trace out(_traceLevels->logger, _traceLevels->activatorCat); + out << "cannot convert `" << pwd << "' into an absolute path"; + } throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path."); } pwd = absbuf; diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index cc32ab551dd..25ba211b3bb 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -1044,6 +1044,7 @@ ServerI::activationFailed(bool destroyed) { } } + if(command) { command->execute(); @@ -1128,19 +1129,12 @@ ServerI::activate() failure = os.str(); } - ServerCommandPtr command; { Lock sync(*this); disableOnFailure(); - setStateNoSync(ServerI::Inactive, failure); - command = nextCommand(); + setStateNoSync(ServerI::Deactivating, failure); } - - // - // It's important to notify the adapters after changing the state! - // Otherwise, a race condition could occur if an adapter is - // activated after the notification and the state change. - // + for(ServerAdapterDict::iterator r = adpts.begin(); r != adpts.end(); ++r) { try @@ -1152,10 +1146,7 @@ ServerI::activate() } } - if(command) - { - command->execute(); - } + setState(ServerI::Inactive); } void @@ -1194,7 +1185,7 @@ ServerI::deactivate() } if(_processRegistered && !_process) { - setStateNoSync(DeactivatingWaitForProcess); + setStateNoSync(ServerI::DeactivatingWaitForProcess); return; } process = _process; @@ -1273,31 +1264,10 @@ void ServerI::terminated(const string& msg, int status) { ServerAdapterDict adpts; - { - Lock sync(*this); - adpts = _adapters; - } - - // - // The server has terminated, set its adapter direct proxies to - // null to cause the server re-activation if one of its adapter - // direct proxy is requested. - // - for(ServerAdapterDict::iterator p = adpts.begin(); p != adpts.end(); ++p) - { - try - { - p->second->setDirectProxy(0); - } - catch(const Ice::ObjectNotExistException&) - { - } - } - - ServerCommandPtr command; bool destroying = false; { Lock sync(*this); + adpts = _adapters; // // Clear the process proxy and the pid. @@ -1320,8 +1290,12 @@ ServerI::terminated(const string& msg, int status) { disableOnFailure(); } - - if(_state != ServerI::Destroying) + + if(_state == ServerI::Destroying) + { + destroying = true; + } + else if(_state != ServerI::Deactivating) { ostringstream os; os << "The server terminated unexpectedly"; @@ -1338,22 +1312,33 @@ ServerI::terminated(const string& msg, int status) os << " with exit code " << status; #endif os << (msg.empty() ? "." : ":\n" + msg); - setStateNoSync(ServerI::Inactive, os.str()); - command = nextCommand(); + setStateNoSync(ServerI::Deactivating, os.str()); } - else + } + + // + // The server has terminated, set its adapter direct proxies to + // null to cause the server re-activation if one of its adapter + // direct proxy is requested. + // + for(ServerAdapterDict::iterator p = adpts.begin(); p != adpts.end(); ++p) + { + try + { + p->second->setDirectProxy(0); + } + catch(const Ice::ObjectNotExistException&) { - destroying = true; } } - if(command) + if(destroying) { - command->execute(); + destroy(); } - else if(destroying) + else { - destroy(); + setState(ServerI::Inactive); } } @@ -1709,7 +1694,7 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason) assert(_state == WaitForActivation || _state == ActivationTimeout); break; case Deactivating: - assert(_stop && _stop->canExecute(_state)); + //assert(_stop && _stop->canExecute(_state)); break; case DeactivatingWaitForProcess: assert(_state == Deactivating); @@ -1742,11 +1727,6 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason) { _patch = 0; } - if(_start) - { - _start->failed(reason); - _start = 0; - } if(_stop) { _stop->finished(); @@ -1770,7 +1750,7 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason) case Deactivating: if(_start) { - _start->failed("The server is being deactivated."); + _start->failed(reason.empty() ? string("The server is being deactivated.") : reason); _start = 0; } break; |