summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/Activator.cpp10
-rw-r--r--cpp/src/IceGrid/Internal.ice3
-rw-r--r--cpp/src/IceGrid/Parser.cpp11
-rw-r--r--cpp/src/IceGrid/ServerI.cpp36
4 files changed, 41 insertions, 19 deletions
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index 4d607d551f1..dacdc8519a6 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -172,7 +172,7 @@ int
stringToSignal(const string& str)
{
#ifdef _WIN32
- throw BadSignalException();
+ throw BadSignalException("signals are not supported on Windows");
#else
if(str == ICE_STRING(SIGHUP))
@@ -246,7 +246,7 @@ stringToSignal(const string& str)
return static_cast<int>(signal);
}
}
- throw BadSignalException();
+ throw BadSignalException("unknown signal `" + str + "'");
}
}
#endif
@@ -900,7 +900,7 @@ Activator::sendSignal(const string& name, int signal)
//
// TODO: Win32 implementation?
//
- throw BadSignalException();
+ throw BadSignalException("signals are not supported on Windows");
#else
Ice::Int pid = getServerPid(name);
@@ -1045,6 +1045,10 @@ Activator::deactivateAll()
{
p->second.server->stop_async(0);
}
+ catch(const ServerStopException&)
+ {
+ // Server already stopped or destroyed.
+ }
catch(const ObjectNotExistException&)
{
//
diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice
index c44a07bd467..9135a6b6bc9 100644
--- a/cpp/src/IceGrid/Internal.ice
+++ b/cpp/src/IceGrid/Internal.ice
@@ -114,7 +114,8 @@ interface Server
* amount of time, it will be killed.
*
**/
- ["amd"] void stop();
+ ["amd"] void stop()
+ throws ServerStopException;
/**
*
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index 379bf7989c8..c2fea1297fd 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -698,6 +698,10 @@ Parser::stopServer(const list<string>& args)
{
_admin->stopServer(args.front());
}
+ catch(const ServerStopException& ex)
+ {
+ error("the server didn't stop successfully:\n" + ex.reason);
+ }
catch(const Ice::Exception& ex)
{
exception(ex);
@@ -852,6 +856,11 @@ Parser::stateServer(const list<string>& args)
cout << "deactivating (" << enabled << ")" << endl;
break;
}
+ case Destroying:
+ {
+ cout << "destroying (" << enabled << ")" << endl;
+ break;
+ }
case Destroyed:
{
cout << "destroyed (" << enabled << ")" << endl;
@@ -1558,7 +1567,7 @@ Parser::exception(const Ice::Exception& ex)
catch(const BadSignalException& ex)
{
ostringstream s;
- s << ex;
+ s << ex.reason;
error(s.str());
}
catch(const NodeUnreachableException& ex)
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index e697ba17b74..2544c99dad5 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -329,12 +329,6 @@ public:
{
}
- static bool
- isStarted(ServerI::InternalServerState state)
- {
- return state == ServerI::ActivationTimeout || state == ServerI::Active;
- }
-
virtual bool
canExecute(ServerI::InternalServerState state)
{
@@ -441,6 +435,18 @@ public:
}
void
+ failed(const string& reason)
+ {
+ stopTimer();
+ ServerStopException ex(_server->getId(), reason);
+ for(vector<AMD_Server_stopPtr>::const_iterator p = _stopCB.begin(); p != _stopCB.end(); ++p)
+ {
+ (*p)->ice_exception(ex);
+ }
+ _stopCB.clear();
+ }
+
+ void
finished()
{
stopTimer();
@@ -607,14 +613,16 @@ ServerI::stop_async(const AMD_Server_stopPtr& amdCB, const Ice::Current&)
{
Lock sync(*this);
checkDestroyed();
+
if(StopCommand::isStopped(_state))
{
- if(amdCB)
- {
- amdCB->ice_response();
- }
- return;
+ throw ServerStopException(_id, "The server is already inactive.");
+ }
+ else if(_state == Destroying)
+ {
+ throw ServerStopException(_id, "The server is being destroyed.");
}
+
if(!_stop)
{
_stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
@@ -2044,13 +2052,13 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason)
_start->failed("The server is being destroyed.");
_start = 0;
}
- break;
- case Destroyed:
if(_stop)
{
- _stop->finished();
+ _stop->failed("The server is being destroyed.");
_stop = 0;
}
+ break;
+ case Destroyed:
if(_destroy)
{
_destroy->finished();