diff options
author | Marc Laukien <marc@zeroc.com> | 2001-08-24 17:27:25 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-08-24 17:27:25 +0000 |
commit | add66270642327b37f735b0335e59f26081d528d (patch) | |
tree | 2bddf561151d59aa647754572d2b369bd13e4d85 /cpp | |
parent | no output for empty block start/end (diff) | |
download | ice-add66270642327b37f735b0335e59f26081d528d.tar.bz2 ice-add66270642327b37f735b0335e59f26081d528d.tar.xz ice-add66270642327b37f735b0335e59f26081d528d.zip |
Activator
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Ice/hello/Client.cpp | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/Server.cpp | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/latency/Client.cpp | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/latency/Server.cpp | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/value/Client.cpp | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/value/Server.cpp | 2 | ||||
-rw-r--r-- | cpp/doc/Properties.sgml | 32 | ||||
-rw-r--r-- | cpp/include/Ice/Initialize.h | 2 | ||||
-rw-r--r-- | cpp/slice/IcePack/AdminF.ice | 1 | ||||
-rw-r--r-- | cpp/src/Ice/.depend | 2 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/Network.cpp | 132 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 41 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.h | 8 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 14 | ||||
-rw-r--r-- | cpp/src/IcePack/.depend | 5 | ||||
-rw-r--r-- | cpp/src/IcePack/Activator.cpp | 192 | ||||
-rw-r--r-- | cpp/src/IcePack/Activator.h | 54 | ||||
-rw-r--r-- | cpp/src/IcePack/AdminI.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IcePack/AdminI.h | 5 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.cpp | 7 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.h | 7 | ||||
-rw-r--r-- | cpp/src/IcePack/Makefile | 3 |
23 files changed, 470 insertions, 69 deletions
diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp index e4f1e8e7b05..b25d03d646f 100644 --- a/cpp/demo/Ice/hello/Client.cpp +++ b/cpp/demo/Ice/hello/Client.cpp @@ -83,7 +83,7 @@ main(int argc, char* argv[]) try { - Ice::PropertiesPtr properties = Ice::loadProperties(argc, argv, "config"); + Ice::PropertiesPtr properties = Ice::createPropertiesFromFile(argc, argv, "config"); communicator = Ice::initializeWithProperties(properties); status = run(argc, argv, communicator); } diff --git a/cpp/demo/Ice/hello/Server.cpp b/cpp/demo/Ice/hello/Server.cpp index 2102b3c59b0..6861ca03656 100644 --- a/cpp/demo/Ice/hello/Server.cpp +++ b/cpp/demo/Ice/hello/Server.cpp @@ -32,7 +32,7 @@ main(int argc, char* argv[]) try { - Ice::PropertiesPtr properties = Ice::loadProperties(argc, argv, "config"); + Ice::PropertiesPtr properties = Ice::createPropertiesFromFile(argc, argv, "config"); communicator = Ice::initializeWithProperties(properties); status = run(argc, argv, communicator); } diff --git a/cpp/demo/Ice/latency/Client.cpp b/cpp/demo/Ice/latency/Client.cpp index 56e6cfb4697..b08993da888 100644 --- a/cpp/demo/Ice/latency/Client.cpp +++ b/cpp/demo/Ice/latency/Client.cpp @@ -88,7 +88,7 @@ main(int argc, char* argv[]) try { - Ice::PropertiesPtr properties = Ice::loadProperties(argc, argv, "config"); + Ice::PropertiesPtr properties = Ice::createPropertiesFromFile(argc, argv, "config"); communicator = Ice::initializeWithProperties(properties); status = run(argc, argv, communicator); } diff --git a/cpp/demo/Ice/latency/Server.cpp b/cpp/demo/Ice/latency/Server.cpp index 25eaacb4ca7..7c998f00648 100644 --- a/cpp/demo/Ice/latency/Server.cpp +++ b/cpp/demo/Ice/latency/Server.cpp @@ -32,7 +32,7 @@ main(int argc, char* argv[]) try { - Ice::PropertiesPtr properties = Ice::loadProperties(argc, argv, "config"); + Ice::PropertiesPtr properties = Ice::createPropertiesFromFile(argc, argv, "config"); communicator = Ice::initializeWithProperties(properties); status = run(argc, argv, communicator); } diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index 6a915e4eedc..4a55e10a7ef 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -167,7 +167,7 @@ main(int argc, char* argv[]) try { - Ice::PropertiesPtr properties = Ice::loadProperties(argc, argv, "config"); + Ice::PropertiesPtr properties = Ice::createPropertiesFromFile(argc, argv, "config"); communicator = Ice::initializeWithProperties(properties); status = run(argc, argv, communicator); } diff --git a/cpp/demo/Ice/value/Server.cpp b/cpp/demo/Ice/value/Server.cpp index 21101d22ae5..0eb18ccc795 100644 --- a/cpp/demo/Ice/value/Server.cpp +++ b/cpp/demo/Ice/value/Server.cpp @@ -32,7 +32,7 @@ main(int argc, char* argv[]) try { - Ice::PropertiesPtr properties = Ice::loadProperties(argc, argv, "config"); + Ice::PropertiesPtr properties = Ice::createPropertiesFromFile(argc, argv, "config"); communicator = Ice::initializeWithProperties(properties); status = run(argc, argv, communicator); } diff --git a/cpp/doc/Properties.sgml b/cpp/doc/Properties.sgml index 54f86fe2a05..d8af3b26d40 100644 --- a/cpp/doc/Properties.sgml +++ b/cpp/doc/Properties.sgml @@ -122,7 +122,6 @@ The request retry tracing level: <!-- ********************************************************************** --> <section><title>Ice.Adapter.<replaceable>name</replaceable>.Endpoints</title> - <section><title>Synopsis</title> <synopsis> Ice.Adapter.<replaceable>name</replaceable>.Endpoints=<replaceable>endpoints</replaceable> @@ -138,6 +137,28 @@ Sets the endpoints for the object adapter </section> </section> +<section><title>Ice.Adapter.Forward.Endpoints</title> +<section><title>Synopsis</title> +<synopsis> +Ice.Adapter.Forward.Endpoints=<replaceable>endpoints</replaceable> +</synopsis> +</section> +<section> +<title>Description</title> +<para> +<replaceable>endpoints</replaceable> are the &IcePack; location +forward endpoints. Set this property if you want &Ice; to create +references that point to the &IcePack; location forwarder. +<note> +<para> +Do not use an Object Adapter with the name <literal>Forward</literal> +in your own applications. +</para> +</note> +</para> +</section> +</section> + </section> <!-- ********************************************************************** --> @@ -145,7 +166,6 @@ Sets the endpoints for the object adapter <!-- ********************************************************************** --> <section><title>Ice.ThreadPool.Size</title> - <section><title>Synopsis</title> <synopsis> Ice.ThreadPool.Size=<replaceable>num</replaceable> @@ -170,8 +190,8 @@ The number of threads in the thread pool. Default is 10. <section><title>Synopsis</title> <synopsis> Ice.Daemon=<replaceable>num</replaceable> -Ice.DaemonNoClose=<replaceable>noclose</replaceable> -Ice.DaemonNoChdir=<replaceable>nochdir</replaceable> +Ice.DaemonNoClose=<replaceable>no_close</replaceable> +Ice.DaemonNoChdir=<replaceable>no_chdir</replaceable> </synopsis> </section> <section> @@ -180,9 +200,9 @@ Ice.DaemonNoChdir=<replaceable>nochdir</replaceable> If <replaceable>num</replaceable> is set to a value larger than zero, the &Ice; process daeamonizes itself with the <literal>daemon</literal> system call. If -<replaceable>noclose</replaceable> is set to a value larger than zero, +<replaceable>no_close</replaceable> is set to a value larger than zero, standard input, output, and error output are not redirected to -<literal>/dev/null</literal>. If <replaceable>nochdir</replaceable> is +<literal>/dev/null</literal>. If <replaceable>no_chdir</replaceable> is set to a value larger than zero, &Ice; doesn't change its working directory to the root directory. (Unix only.) </para> diff --git a/cpp/include/Ice/Initialize.h b/cpp/include/Ice/Initialize.h index 9518cee392d..8e2c5db977f 100644 --- a/cpp/include/Ice/Initialize.h +++ b/cpp/include/Ice/Initialize.h @@ -19,7 +19,7 @@ ICE_API CommunicatorPtr initializeWithProperties(const PropertiesPtr&, Int = ICE ICE_API PropertiesPtr getDefaultProperties(int&, char*[]); ICE_API PropertiesPtr createProperties(int&, char*[]); -ICE_API PropertiesPtr loadProperties(int&, char*[], const std::string&); +ICE_API PropertiesPtr createPropertiesFromFile(int&, char*[], const std::string&); } diff --git a/cpp/slice/IcePack/AdminF.ice b/cpp/slice/IcePack/AdminF.ice index 9d3537bf101..247efb9c8eb 100644 --- a/cpp/slice/IcePack/AdminF.ice +++ b/cpp/slice/IcePack/AdminF.ice @@ -14,6 +14,7 @@ module IcePack { +class ServerDescription; class Admin; }; diff --git a/cpp/src/Ice/.depend b/cpp/src/Ice/.depend index 206bd9f69c2..db7f8cf093b 100644 --- a/cpp/src/Ice/.depend +++ b/cpp/src/Ice/.depend @@ -10,7 +10,7 @@ LoggerI.o: LoggerI.cpp ../Ice/LoggerI.h ../../include/Ice/Logger.h ../../include SysLoggerI.o: SysLoggerI.cpp ../Ice/SysLoggerI.h ../../include/Ice/Logger.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h TraceLevels.o: TraceLevels.cpp ../Ice/TraceLevels.h ../Ice/TraceLevelsF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/PropertiesF.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 ../../include/Ice/Properties.h TraceUtil.o: TraceUtil.cpp ../Ice/TraceUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../Ice/TraceLevelsF.h ../Ice/Instance.h ../../include/Ice/InstanceF.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/EmitterF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/PicklerF.h ../Ice/TraceLevels.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h -Instance.o: Instance.cpp ../Ice/Instance.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/CommunicatorF.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 ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../Ice/TraceLevelsF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/EmitterF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/PicklerF.h ../Ice/TraceLevels.h ../Ice/ProxyFactory.h ../../include/Ice/ReferenceF.h ../Ice/ThreadPool.h ../Ice/EventHandlerF.h ../Ice/Emitter.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/EndpointF.h ../Ice/EventHandler.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../Ice/ValueFactoryManager.h ../../include/Ice/ValueFactoryF.h ../Ice/ObjectAdapterFactory.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../Ice/LoggerI.h ../../include/Ice/Logger.h ../Ice/SysLoggerI.h ../Ice/PicklerI.h ../../include/Ice/Pickler.h +Instance.o: Instance.cpp ../Ice/Instance.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/CommunicatorF.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 ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../Ice/TraceLevelsF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/EmitterF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/PicklerF.h ../Ice/TraceLevels.h ../Ice/ProxyFactory.h ../../include/Ice/ReferenceF.h ../Ice/ThreadPool.h ../Ice/EventHandlerF.h ../Ice/Emitter.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/EndpointF.h ../Ice/EventHandler.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../Ice/ValueFactoryManager.h ../../include/Ice/ValueFactoryF.h ../Ice/ObjectAdapterFactory.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../Ice/LoggerI.h ../../include/Ice/Logger.h ../Ice/PicklerI.h ../../include/Ice/Pickler.h ../Ice/SysLoggerI.h Communicator.o: Communicator.cpp ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h CommunicatorI.o: CommunicatorI.cpp ../Ice/CommunicatorI.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/Communicator.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 ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../Ice/PropertiesI.h ../../include/Ice/Properties.h ../Ice/Instance.h ../../include/Ice/CommunicatorF.h ../Ice/TraceLevelsF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/EmitterF.h ../Ice/ValueFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/ProxyFactory.h ../../include/Ice/ReferenceF.h ../Ice/ThreadPool.h ../Ice/EventHandlerF.h ../../include/Ice/ObjectAdapter.h ../Ice/ValueFactoryManager.h ../Ice/ObjectAdapterFactory.h ../../include/Ice/Logger.h ../../include/Ice/Initialize.h ../../include/Ice/LocalException.h ObjectAdapter.o: ObjectAdapter.cpp ../../include/Ice/ObjectAdapter.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/CommunicatorF.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index 4d0f63979a1..e96b41cac50 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -206,15 +206,7 @@ Ice::getDefaultProperties(int& argc, char* argv[]) { if (!defaultProperties) { - const char* file = getenv("ICE_CONFIG"); - if (file && *file != '\0') - { - defaultProperties = new PropertiesI(argc, argv, file); - } - else - { - defaultProperties = new PropertiesI(argc, argv); - } + defaultProperties = createProperties(argc, argv); } return defaultProperties; } @@ -226,7 +218,7 @@ Ice::createProperties(int& argc, char* argv[]) } PropertiesPtr -Ice::loadProperties(int& argc, char* argv[], const std::string& file) +Ice::createPropertiesFromFile(int& argc, char* argv[], const string& file) { return new PropertiesI(argc, argv, file); } diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 94a5c947ed4..f2c7cb3e505 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -22,14 +22,20 @@ IceInternal::interrupted() #ifdef WIN32 int error = WSAGetLastError(); if (error == WSAEINTR) + { return true; + } #else if (errno == EINTR || - errno == EPROTO) + errno == EPROTO) + { return true; + } #endif else + { return false; + } } bool @@ -41,17 +47,23 @@ IceInternal::acceptInterrupted() #ifdef WIN32 int error = WSAGetLastError(); if (error == WSAECONNABORTED || - error == WSAECONNRESET || - error == WSAETIMEDOUT) + error == WSAECONNRESET || + error == WSAETIMEDOUT) + { return true; + } #else if (errno == ECONNABORTED || - errno == ECONNRESET || - errno == ETIMEDOUT) + errno == ECONNRESET || + errno == ETIMEDOUT) + { return true; + } #endif else + { return false; + } } bool @@ -60,14 +72,20 @@ IceInternal::noBuffers() #ifdef WIN32 int error = WSAGetLastError(); if (error == WSAENOBUFS || - error == WSAEFAULT) + error == WSAEFAULT) + { return true; + } #else if (errno == ENOBUFS) + { return true; + } #endif else + { return false; + } } bool @@ -76,14 +94,20 @@ IceInternal::wouldBlock() #ifdef WIN32 int error = WSAGetLastError(); if (error == WSAEWOULDBLOCK) + { return true; + } #else if (errno == EAGAIN || - errno == EWOULDBLOCK) + errno == EWOULDBLOCK) + { return true; + } #endif else + { return false; + } } bool @@ -92,23 +116,29 @@ IceInternal::connectFailed() #ifdef WIN32 int error = WSAGetLastError(); if (error == WSAECONNREFUSED || - error == WSAETIMEDOUT || - error == WSAENETUNREACH || - error == WSAECONNRESET || - error == WSAESHUTDOWN || - error == WSAECONNABORTED) + error == WSAETIMEDOUT || + error == WSAENETUNREACH || + error == WSAECONNRESET || + error == WSAESHUTDOWN || + error == WSAECONNABORTED) + { return true; + } #else if (errno == ECONNREFUSED || - errno == ETIMEDOUT || - errno == ENETUNREACH || - errno == ECONNRESET || - errno == ESHUTDOWN || - errno == ECONNABORTED) + errno == ETIMEDOUT || + errno == ENETUNREACH || + errno == ECONNRESET || + errno == ESHUTDOWN || + errno == ECONNABORTED) + { return true; + } #endif else + { return false; + } } bool @@ -117,13 +147,19 @@ IceInternal::connectInProgress() #ifdef WIN32 int error = WSAGetLastError(); if (error == WSAEWOULDBLOCK) + { return true; + } #else if (errno == EINPROGRESS) + { return true; + } #endif else + { return false; + } } bool @@ -132,17 +168,23 @@ IceInternal::connectionLost() #ifdef WIN32 int error = WSAGetLastError(); if (error == WSAECONNRESET || - error == WSAESHUTDOWN || - error == WSAECONNABORTED) + error == WSAESHUTDOWN || + error == WSAECONNABORTED) + { return true; + } #else if (errno == ECONNRESET || - errno == ESHUTDOWN || - errno == ECONNABORTED) + errno == ESHUTDOWN || + errno == ECONNABORTED) + { return true; + } #endif else + { return false; + } } bool @@ -151,13 +193,19 @@ IceInternal::notConnected() #ifdef WIN32 int error = WSAGetLastError(); if (error == WSAENOTCONN) + { return true; + } #else if (errno == ENOTCONN) + { return true; + } #endif else + { return false; + } } int @@ -166,12 +214,18 @@ IceInternal::createSocket(bool udp) int fd; if (udp) + { fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); + } else + { fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + } if (fd == INVALID_SOCKET) + { throw SocketException(__FILE__, __LINE__); + } setBlock(fd, false); @@ -287,7 +341,9 @@ repeatListen: if (::listen(fd, backlog) == SOCKET_ERROR) { if (interrupted()) + { goto repeatListen; + } closeSocket(fd); throw SocketException(__FILE__, __LINE__); @@ -309,7 +365,9 @@ repeatConnect: if (::connect(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) { if (interrupted()) + { goto repeatConnect; + } if (connectInProgress()) { @@ -355,7 +413,9 @@ repeatConnect: else if (ret == SOCKET_ERROR) { if (interrupted()) + { goto repeatSelect; + } throw SocketException(__FILE__, __LINE__); } @@ -385,9 +445,13 @@ repeatConnect: errno = val; #endif if (connectFailed()) + { throw ConnectFailedException(__FILE__, __LINE__); + } else + { throw SocketException(__FILE__, __LINE__); + } } return; @@ -395,9 +459,13 @@ repeatConnect: closeSocket(fd); if (connectFailed()) + { throw ConnectFailedException(__FILE__, __LINE__); + } else + { throw SocketException(__FILE__, __LINE__); + } } } @@ -410,7 +478,9 @@ repeatAccept: if ((ret = ::accept(fd, 0, 0)) == INVALID_SOCKET) { if (acceptInterrupted()) + { goto repeatAccept; + } if (wouldBlock()) { @@ -434,13 +504,17 @@ repeatAccept: if (ret == SOCKET_ERROR) { if (interrupted()) + { goto repeatSelect; + } throw SocketException(__FILE__, __LINE__); } if (ret == 0) + { throw TimeoutException(__FILE__, __LINE__); + } goto repeatAccept; } @@ -491,7 +565,9 @@ IceInternal::getAddress(const char* host, int port, struct sockaddr_in& addr) #endif if (!entry) + { throw DNSException(__FILE__, __LINE__); + } memcpy(&addr.sin_addr, entry->h_addr, entry->h_length); } @@ -502,7 +578,9 @@ IceInternal::getLocalAddress(int port, struct sockaddr_in& addr) { char host[1024 + 1]; if (gethostname(host, 1024) == -1) + { throw SystemException(__FILE__, __LINE__); + } memset(&addr, 0, sizeof(struct sockaddr_in)); addr.sin_family = AF_INET; @@ -525,7 +603,9 @@ IceInternal::getLocalAddress(int port, struct sockaddr_in& addr) #endif if (!entry) + { throw DNSException(__FILE__, __LINE__); + } memcpy(&addr.sin_addr, entry->h_addr, entry->h_length); } @@ -536,7 +616,9 @@ IceInternal::getLocalHost(bool numeric) { char host[1024 + 1]; if (gethostname(host, 1024) == -1) + { throw SystemException(__FILE__, __LINE__); + } { JTCSyncT<JTCMutex> sync(getHostByNameMutex); @@ -545,7 +627,9 @@ IceInternal::getLocalHost(bool numeric) int retry = 5; do + { entry = gethostbyname(host); + } #ifdef WIN32 while (!entry && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0); #else @@ -553,7 +637,9 @@ IceInternal::getLocalHost(bool numeric) #endif if (!entry) + { throw DNSException(__FILE__, __LINE__); + } if (numeric) { @@ -563,7 +649,9 @@ IceInternal::getLocalHost(bool numeric) return string(inet_ntoa(addr.sin_addr)); } else + { return string(entry->h_name); + } } } @@ -610,7 +698,9 @@ IceInternal::createPipe(int fds[2]) #else if (::pipe(fds) != 0) + { throw SystemException(__FILE__, __LINE__); + } #endif } diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 84cf6c09e77..62bf6f330b0 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -47,13 +47,48 @@ Ice::PropertiesI::clone() Ice::PropertiesI::PropertiesI(int& argc, char* argv[]) { + for (int i = 1; i < argc; ++i) + { + if (strncmp(argv[i], "--Ice.Config", 12) == 0) + { + string line = argv[i]; + if (line.find('=') == string::npos) + { + line += "=1"; + } + parseLine(line.substr(2)); + } + } + + string file = getProperty("Ice.Config"); + + if (file.empty() || file == "1") + { + const char* s = getenv("ICE_CONFIG"); + if (s && *s != '\0') + { + file = s; + } + } + + if (!file.empty()) + { + load(file); + } + parseArgs(argc, argv); + setProperty("Ice.Config", file); } Ice::PropertiesI::PropertiesI(int& argc, char* argv[], const string& file) { - load(file); + if (!file.empty()) + { + load(file); + } + parseArgs(argc, argv); + setProperty("Ice.Config", file); } void @@ -90,7 +125,7 @@ Ice::PropertiesI::parseArgs(int& argc, char* argv[]) line += "=1"; } - parseLine(line.c_str() + 2); + parseLine(line.substr(2)); } else { @@ -121,7 +156,7 @@ Ice::PropertiesI::parse(istream& in) } void -Ice::PropertiesI::parseLine(const char* line) +Ice::PropertiesI::parseLine(const string& line) { const string delim = " \t"; string s = line; diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h index a30fa1e1f57..651ac559543 100644 --- a/cpp/src/Ice/PropertiesI.h +++ b/cpp/src/Ice/PropertiesI.h @@ -28,16 +28,14 @@ public: private: PropertiesI(int&, char*[]); - PropertiesI(int&, char*[], const std::string&); - - friend ICE_API PropertiesPtr getDefaultProperties(int&, char*[]); + PropertiesI(int&, char*[], const std::string& file); friend ICE_API PropertiesPtr createProperties(int&, char*[]); - friend ICE_API PropertiesPtr loadProperties(int&, char*[], const std::string&); + friend ICE_API PropertiesPtr createPropertiesFromFile(int&, char*[], const std::string&); void parseArgs(int&, char*[]); void load(const std::string&); void parse(std::istream&); - void parseLine(const char*); + void parseLine(const std::string&); std::map<std::string, std::string> _properties; }; diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index f3547e79bda..d9adeb90dd2 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -15,7 +15,9 @@ #include <Ice/Instance.h> #include <Ice/Communicator.h> #include <Ice/Properties.h> +#include <Ice/Logger.h> #include <Ice/Functional.h> +#include <sstream> using namespace std; using namespace Ice; @@ -244,7 +246,7 @@ IceInternal::ThreadPool::run() return; } - if (FD_ISSET(_fdIntrRead, &fdSet)) // Clear interrupt + if (FD_ISSET(_fdIntrRead, &fdSet)) { clearInterrupt(); #ifdef WIN32 @@ -421,15 +423,19 @@ IceInternal::ThreadPool::EventHandlerThread::run() } catch (const LocalException& ex) { - cerr << ex << endl; + ostringstream s; + s << "exception in thread pool:\n" << ex; + _pool->_instance->logger()->error(s.str()); } catch (const JTCException& ex) { - cerr << ex << endl; + ostringstream s; + s << "exception in thread pool:\n" << ex; + _pool->_instance->logger()->error(s.str()); } catch (...) { - cerr << "unknown exception" << endl; + _pool->_instance->logger()->error("unknown exception in thread pool"); } _pool = 0; // Break cyclic dependency diff --git a/cpp/src/IcePack/.depend b/cpp/src/IcePack/.depend index a06b8b102a4..d79849595ff 100644 --- a/cpp/src/IcePack/.depend +++ b/cpp/src/IcePack/.depend @@ -3,6 +3,7 @@ Grammer.o: Grammer.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h Scanner.o: Scanner.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Grammer.h Parser.o: Parser.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h Client.o: Client.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h -Server.o: Server.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Forward.h -Forward.o: Forward.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Forward.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h +Server.o: Server.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Forward.h ../../include/IcePack/AdminF.h +Forward.o: Forward.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Forward.h ../../include/IcePack/AdminF.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/IcePack/Admin.h AdminI.o: AdminI.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h +Activator.o: Activator.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Activator.h ../../include/IcePack/AdminF.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/IcePack/Admin.h diff --git a/cpp/src/IcePack/Activator.cpp b/cpp/src/IcePack/Activator.cpp new file mode 100644 index 00000000000..2d0aedf6cf4 --- /dev/null +++ b/cpp/src/IcePack/Activator.cpp @@ -0,0 +1,192 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <IcePack/Activator.h> +#include <IcePack/Admin.h> +#include <sstream> +#include <fcntl.h> + +using namespace std; +using namespace Ice; +using namespace IcePack; + +IcePack::Activator::Activator(const CommunicatorPtr& communicator) : + _communicator(communicator), + _destroy(false) +{ + int fds[2]; + if (::pipe(fds) != 0) + { + throw SystemException(__FILE__, __LINE__); + } + _fdIntrRead = fds[0]; + _fdIntrWrite = fds[1]; + int flags = fcntl(_fdIntrRead, F_GETFL); + flags |= O_NONBLOCK; + fcntl(_fdIntrRead, F_SETFL, flags); +} + +IcePack::Activator::~Activator() +{ + assert(_destroy); + close(_fdIntrRead); + close(_fdIntrWrite); + for (map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p) + { + close(p->second.fd); + } +} + +void +IcePack::Activator::run() +{ + try + { + terminationListener(); + } + catch (const LocalException& ex) + { + ostringstream s; + s << "exception in process termination listener:\n" << ex; + _communicator->getLogger()->error(s.str()); + } + catch (const JTCException& ex) + { + ostringstream s; + s << "exception in process termination listener:\n" << ex; + _communicator->getLogger()->error(s.str()); + } + catch (...) + { + _communicator->getLogger()->error("unknown exception in process termination listener"); + } +} + +void +IcePack::Activator::destroy() +{ + JTCSyncT<JTCMonitor> sync(*this); + + if (!_destroy) // Don't destroy twice + { + _destroy = true; + setInterrupt(); + } +} + +void +IcePack::Activator::activate(const ServerDescriptionPtr& desc) +{ +} + +void +IcePack::Activator::terminationListener() +{ + while (true) + { + fd_set fdSet; + int maxFd = _fdIntrRead; + FD_ZERO(&fdSet); + FD_SET(_fdIntrRead, &fdSet); + + { + JTCSyncT<JTCMonitor> sync(*this); + + if (_destroy) + { + return; + } + + for (map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p) + { + int fd = p->second.fd; + FD_SET(fd, &fdSet); + if (maxFd < fd) + { + maxFd = fd; + } + } + } + + repeatSelect: + int ret = ::select(maxFd + 1, &fdSet, 0, 0, 0); + assert(ret != 0); + + if (ret == -1) + { + if (errno == EINTR || errno == EPROTO) + { + goto repeatSelect; + } + + throw SystemException(__FILE__, __LINE__); + } + + { + JTCSyncT<JTCMonitor> sync(*this); + + if (FD_ISSET(_fdIntrRead, &fdSet)) + { + clearInterrupt(); + } + + if (_destroy) + { + return; + } + + map<string, Process>::iterator p = _processes.begin(); + while (p != _processes.end()) + { + int fd = p->second.fd; + if (FD_ISSET(fd, &fdSet)) + { + char c; + int ret = ::read(fd, &c, 1); + if (ret == -1) + { + throw SystemException(__FILE__, __LINE__); + } + + // + // Either the pipe was closed, which means that + // the process has terminated. Or the process is + // misbehaving and sending some garbage data. In + // both cases we remove the process. + // + map<string, Process>::iterator q = p; + ++p; + _processes.erase(q); + close(fd); + } + else + { + ++p; + } + } + } + } +} + +void +IcePack::Activator::clearInterrupt() +{ + char s[32]; // Clear up to 32 interrupts at once + while (::read(_fdIntrRead, s, 32) == 32) + ; +} + +void +IcePack::Activator::setInterrupt() +{ + char c = 0; + ::write(_fdIntrWrite, &c, 1); +} diff --git a/cpp/src/IcePack/Activator.h b/cpp/src/IcePack/Activator.h new file mode 100644 index 00000000000..2c12300b85c --- /dev/null +++ b/cpp/src/IcePack/Activator.h @@ -0,0 +1,54 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#ifndef ICE_PACK_ACTIVATOR_H +#define ICE_PACK_ACTIVATOR_H + +#include <IcePack/AdminF.h> +#include <map> + +namespace IcePack +{ + +class Activator : public JTCThread, public JTCMonitor +{ +public: + + Activator(const Ice::CommunicatorPtr&); + virtual ~Activator(); + + virtual void run(); + void destroy(); + void activate(const IcePack::ServerDescriptionPtr&); + +private: + + void terminationListener(); + void clearInterrupt(); + void setInterrupt(); + + struct Process + { + int pid; + int fd; + }; + + Ice::CommunicatorPtr _communicator; + std::map<std::string, Process> _processes; + bool _destroy; + int _fdIntrRead; + int _fdIntrWrite; +}; + +typedef JTCHandleT<Activator> ActivatorHandle; + +} + +#endif diff --git a/cpp/src/IcePack/AdminI.cpp b/cpp/src/IcePack/AdminI.cpp index 6829d012152..f5ea3ccf9f1 100644 --- a/cpp/src/IcePack/AdminI.cpp +++ b/cpp/src/IcePack/AdminI.cpp @@ -15,13 +15,13 @@ using namespace std; using namespace Ice; using namespace IcePack; -AdminI::AdminI(const CommunicatorPtr& communicator) : +IcePack::AdminI::AdminI(const CommunicatorPtr& communicator) : _communicator(communicator) { } void -AdminI::add(const ServerDescriptionPtr& p) +IcePack::AdminI::add(const ServerDescriptionPtr& p) { JTCSyncT<JTCMutex> sync(*this); @@ -32,7 +32,7 @@ AdminI::add(const ServerDescriptionPtr& p) } void -AdminI::remove(const ObjectPrx& p) +IcePack::AdminI::remove(const ObjectPrx& p) { JTCSyncT<JTCMutex> sync(*this); @@ -43,7 +43,7 @@ AdminI::remove(const ObjectPrx& p) } ServerDescriptionPtr -AdminI::find(const ObjectPrx& p) +IcePack::AdminI::find(const ObjectPrx& p) { JTCSyncT<JTCMutex> sync(*this); @@ -66,7 +66,7 @@ AdminI::find(const ObjectPrx& p) } void -AdminI::shutdown() +IcePack::AdminI::shutdown() { _communicator->shutdown(); } diff --git a/cpp/src/IcePack/AdminI.h b/cpp/src/IcePack/AdminI.h index 8541f1a2f63..ebf8a7c7dca 100644 --- a/cpp/src/IcePack/AdminI.h +++ b/cpp/src/IcePack/AdminI.h @@ -14,6 +14,9 @@ #include <IcePack/Admin.h> #include <map> +namespace IcePack +{ + class AdminI : public IcePack::Admin, public JTCMutex { public: @@ -31,4 +34,6 @@ private: std::map<Ice::ObjectPrx, IcePack::ServerDescriptionPtr> _map; }; +} + #endif diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp index 91b85dfd06a..1ae63177edb 100644 --- a/cpp/src/IcePack/Forward.cpp +++ b/cpp/src/IcePack/Forward.cpp @@ -10,18 +10,19 @@ #include <Ice/Ice.h> #include <IcePack/Forward.h> +#include <IcePack/Admin.h> using namespace std; using namespace Ice; using namespace IcePack; -Forward::Forward(const AdminPtr& admin) : +IcePack::Forward::Forward(const AdminPtr& admin) : _admin(admin) { } ObjectPtr -Forward::locate(const ObjectAdapterPtr& adapter, const string& identity, ObjectPtr&) +IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity, ObjectPtr&) { ObjectPrx proxy = adapter->identityToProxy(identity); ServerDescriptionPtr desc = _admin->find(proxy); @@ -34,7 +35,7 @@ Forward::locate(const ObjectAdapterPtr& adapter, const string& identity, ObjectP } void -Forward::finished(const ObjectAdapterPtr&, const string&, const ObjectPtr&, const ObjectPtr&) +IcePack::Forward::finished(const ObjectAdapterPtr&, const string&, const ObjectPtr&, const ObjectPtr&) { // Nothing to do } diff --git a/cpp/src/IcePack/Forward.h b/cpp/src/IcePack/Forward.h index b3e56a8eb5d..64edb6beacf 100644 --- a/cpp/src/IcePack/Forward.h +++ b/cpp/src/IcePack/Forward.h @@ -11,9 +11,12 @@ #ifndef ICE_PACK_FORWARD_H #define ICE_PACK_FORWARD_H -#include <IcePack/Admin.h> +#include <IcePack/AdminF.h> #include <map> +namespace IcePack +{ + class Forward : public Ice::ObjectLocator { public: @@ -29,4 +32,6 @@ private: IcePack::AdminPtr _admin; }; +} + #endif diff --git a/cpp/src/IcePack/Makefile b/cpp/src/IcePack/Makefile index 916873c29a6..90739f8e7a9 100644 --- a/cpp/src/IcePack/Makefile +++ b/cpp/src/IcePack/Makefile @@ -30,7 +30,8 @@ COBJS = Grammer.o \ SOBJS = Server.o \ Forward.o \ - AdminI.o + AdminI.o \ + Activator.o SRCS = $(OBJS:.o=.cpp) \ $(COBJS:.o=.cpp) \ |