summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/.depend2
-rw-r--r--cpp/src/IcePack/Activator.cpp13
-rw-r--r--cpp/src/IcePack/Activator.h2
-rw-r--r--cpp/src/IcePack/Forward.cpp106
4 files changed, 111 insertions, 12 deletions
diff --git a/cpp/src/Ice/.depend b/cpp/src/Ice/.depend
index db7f8cf093b..d8ea819cc7c 100644
--- a/cpp/src/Ice/.depend
+++ b/cpp/src/Ice/.depend
@@ -29,7 +29,7 @@ Incoming.o: Incoming.cpp ../../include/Ice/Incoming.h ../../include/Ice/ObjectAd
Emitter.o: Emitter.cpp ../Ice/Emitter.h ../../include/Ice/EmitterF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/ThreadPoolF.h ../Ice/EndpointF.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../Ice/EventHandler.h ../Ice/EventHandlerF.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../Ice/Instance.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/PicklerF.h ../../include/Ice/Logger.h ../Ice/TraceLevels.h ../Ice/TraceUtil.h ../Ice/Transceiver.h ../Ice/Connector.h ../Ice/ThreadPool.h ../Ice/Endpoint.h ../Ice/AcceptorF.h ../../include/Ice/Outgoing.h ../../include/Ice/ReferenceF.h ../../include/Ice/LocalException.h ../../include/Ice/Functional.h
Collector.o: Collector.cpp ../Ice/Collector.h ../../include/Ice/CollectorF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TransceiverF.h ../Ice/AcceptorF.h ../Ice/ThreadPoolF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../Ice/EndpointF.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../Ice/EventHandler.h ../Ice/EventHandlerF.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../Ice/Instance.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/PicklerF.h ../../include/Ice/Logger.h ../Ice/TraceUtil.h ../Ice/Transceiver.h ../Ice/Acceptor.h ../Ice/ThreadPool.h ../../include/Ice/ObjectAdapter.h ../Ice/Endpoint.h ../Ice/ConnectorF.h ../../include/Ice/Incoming.h ../../include/Ice/LocalException.h ../../include/Ice/Functional.h
Network.o: Network.cpp ../Ice/Network.h ../../include/Ice/Config.h ../../include/Ice/LocalException.h
-ThreadPool.o: ThreadPool.cpp ../Ice/ThreadPool.h ../Ice/ThreadPoolF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/EventHandlerF.h ../../include/Ice/Shared.h ../Ice/EventHandler.h ../../include/Ice/Stream.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../Ice/Network.h ../../include/Ice/LocalException.h ../Ice/Instance.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../Ice/TraceLevelsF.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/PicklerF.h ../../include/Ice/Communicator.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/Properties.h ../../include/Ice/Functional.h
+ThreadPool.o: ThreadPool.cpp ../Ice/ThreadPool.h ../Ice/ThreadPoolF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/EventHandlerF.h ../../include/Ice/Shared.h ../Ice/EventHandler.h ../../include/Ice/Stream.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../Ice/Network.h ../../include/Ice/LocalException.h ../Ice/Instance.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../Ice/TraceLevelsF.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/PicklerF.h ../../include/Ice/Communicator.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Functional.h
EventHandler.o: EventHandler.cpp ../Ice/EventHandler.h ../Ice/EventHandlerF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/ThreadPoolF.h ../../include/Ice/Shared.h ../../include/Ice/Stream.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../Ice/Instance.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../Ice/TraceLevelsF.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/PicklerF.h
Connector.o: Connector.cpp ../Ice/Connector.h ../Ice/ConnectorF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../Ice/TransceiverF.h ../../include/Ice/Shared.h
Acceptor.o: Acceptor.cpp ../Ice/Acceptor.h ../Ice/AcceptorF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../Ice/TransceiverF.h ../../include/Ice/Shared.h
diff --git a/cpp/src/IcePack/Activator.cpp b/cpp/src/IcePack/Activator.cpp
index 50cb645f710..d3900db798e 100644
--- a/cpp/src/IcePack/Activator.cpp
+++ b/cpp/src/IcePack/Activator.cpp
@@ -84,20 +84,20 @@ IcePack::Activator::destroy()
setInterrupt();
}
-void
+bool
IcePack::Activator::activate(const ServerDescriptionPtr& desc)
{
JTCSyncT<JTCMutex> sync(*this);
if (_destroy)
{
- return;
+ return false;
}
string path = desc->path;
if (path.empty())
{
- return;
+ return false;
}
//
@@ -118,7 +118,7 @@ IcePack::Activator::activate(const ServerDescriptionPtr& desc)
//
if (_processes.count(path))
{
- return;
+ return false;
}
//
@@ -186,6 +186,8 @@ IcePack::Activator::activate(const ServerDescriptionPtr& desc)
setInterrupt();
}
+
+ return true;
}
void
@@ -259,7 +261,8 @@ IcePack::Activator::terminationListener()
else if(ret == 0)
{
//
- // If the pipe was closed, the process has terminated
+ // If the pipe was closed, the process has
+ // terminated
//
map<string, Process>::iterator q = p;
++p;
diff --git a/cpp/src/IcePack/Activator.h b/cpp/src/IcePack/Activator.h
index 82ef29509a1..a0f6e086fba 100644
--- a/cpp/src/IcePack/Activator.h
+++ b/cpp/src/IcePack/Activator.h
@@ -26,7 +26,7 @@ public:
virtual void run();
void destroy();
- void activate(const IcePack::ServerDescriptionPtr&);
+ bool activate(const IcePack::ServerDescriptionPtr&);
private:
diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp
index fac3185e7f8..ed8b2178307 100644
--- a/cpp/src/IcePack/Forward.cpp
+++ b/cpp/src/IcePack/Forward.cpp
@@ -11,6 +11,7 @@
#include <Ice/Ice.h>
#include <IcePack/Forward.h>
#include <IcePack/Admin.h>
+#include <sstream>
using namespace std;
using namespace Ice;
@@ -32,15 +33,110 @@ IcePack::Forward::~Forward()
ObjectPtr
IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity, ObjectPtr&)
{
+ //
+ // Look up the server description
+ //
ObjectPrx proxy = adapter->identityToProxy(identity);
ServerDescriptionPtr desc = _admin->find(proxy);
- if (desc)
+
+ //
+ // If we didn't find a server description, we return null, meaning
+ // that the client will get an "object not exist" exception.
+ //
+ if (!desc)
{
- assert(desc->object);
- _activator->activate(desc);
- throw LocationForward(desc->object);
+ return 0;
+ }
+
+ //
+ // We only try to activate if we have a path for the server
+ //
+ if (!desc->path.empty())
+ {
+ try
+ {
+ bool doSleep = false;
+ int count = 0;
+ while (true)
+ {
+ try
+ {
+ //
+ // Activate the server. If the server is already
+ // running, this operation does nothing.
+ //
+ if (_activator->activate(desc))
+ {
+ //
+ // If we just activated the server, we sleep
+ // below, to give the server some time to
+ // start up.
+ //
+ doSleep = true;
+ }
+
+ if (doSleep)
+ {
+ sleep(1); // TODO: Make sleep time configurable
+ }
+
+ //
+ // Try to ping the server, to make sure that it is
+ // really running. Note that even if activate()
+ // above returns false, i.e., if activate()
+ // indicates that the server was already running,
+ // it's still possible that the server shut down
+ // in the meantime, for example, because of a
+ // server timeout, a crash, or an explicit
+ // shutdown method.
+ //
+ proxy->_ping();
+
+ //
+ // Everything ok, the server is now up and
+ // running. The ping above also has the effect
+ // that the server idle timeout (if set) has been
+ // reset. If we wouldn't ping, there would be a
+ // higher chance that the server shuts down
+ // because of an idle timeout while we send back
+ // the location forward to the client.
+ //
+ break;
+ }
+ catch(const SocketException&)
+ {
+ //
+ // Ooops, we got a socket exception while trying
+ // to ping the server. Let's set the doSleep flag
+ // to give the server more time before we try
+ // again.
+ //
+ // TODO: Make number of retries configurable,
+ // ideally in Ice itself.
+ //
+ if (++count >= 10)
+ {
+ throw;
+ }
+
+ doSleep = true;
+ }
+ }
+ }
+ catch(const LocalException& ex)
+ {
+ //
+ // If we get an exception, all we an do is to log it and
+ // to send a location forward to the client, which will
+ // then get a similar exception.
+ //
+ ostringstream s;
+ s << "exception during server activation:\n" << ex;
+ _communicator->getLogger()->error(s.str());
+ }
}
- return 0;
+
+ throw LocationForward(desc->object);
}
void