diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/.depend | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 23 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 31 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.h | 1 |
4 files changed, 53 insertions, 4 deletions
diff --git a/cpp/src/Ice/.depend b/cpp/src/Ice/.depend index e20d060cf36..206bd9f69c2 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/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/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/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index fc0243a6549..0f2ac185da6 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -150,6 +150,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope { string value; + // Must be done before "Ice.Daemon" is checked value = properties->getProperty("Ice.PrintProcessId"); if (atoi(value.c_str()) >= 1) { @@ -161,6 +162,28 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope } #ifndef WIN32 + value = properties->getProperty("Ice.Daemon"); + if (atoi(value.c_str()) >= 1) + { + value = properties->getProperty("Ice.DaemonNoClose"); + int noclose = atoi(value.c_str()); + + value = properties->getProperty("Ice.DaemonNoChdir"); + int nochdir = atoi(value.c_str()); + + if (daemon(nochdir, noclose) == -1) + { + --_globalStateCounter; + if (_globalStateMutex != 0) + { + _globalStateMutex->unlock(); + } + throw SystemException(__FILE__, __LINE__); + } + } +#endif + +#ifndef WIN32 value = properties->getProperty("Ice.UseSyslog"); if (atoi(value.c_str()) >= 1) { diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 2f34c72b5d9..f3547e79bda 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -13,6 +13,7 @@ #include <Ice/Network.h> #include <Ice/LocalException.h> #include <Ice/Instance.h> +#include <Ice/Communicator.h> #include <Ice/Properties.h> #include <Ice/Functional.h> @@ -101,7 +102,8 @@ IceInternal::ThreadPool::joinWithAllThreads() IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance) : _instance(instance), _lastFd(-1), - _servers(0) + _servers(0), + _timeout(0) { int fds[2]; createPipe(fds); @@ -138,6 +140,8 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance) : destroy(); throw; } + + _timeout = atoi(_instance->properties()->getProperty("Ice.ServerIdleTime").c_str()); } IceInternal::ThreadPool::~ThreadPool() @@ -193,7 +197,28 @@ IceInternal::ThreadPool::run() repeatSelect: fd_set fdSet; memcpy(&fdSet, &_fdSet, sizeof(fd_set)); - if (::select(_maxFd + 1, &fdSet, 0, 0, 0) == SOCKET_ERROR) + int ret; + if (_timeout) + { + struct timeval tv; + tv.tv_sec = _timeout; + tv.tv_usec = 0; + ret = ::select(_maxFd + 1, &fdSet, 0, 0, &tv); + } + else + { + ret = ::select(_maxFd + 1, &fdSet, 0, 0, 0); + } + + if (ret == 0) // Timeout + { + assert(_timeout); + _timeout = 0; + _instance->communicator()->shutdown(); + goto repeatSelect; + } + + if (ret == SOCKET_ERROR) { if (interrupted()) { @@ -203,7 +228,7 @@ IceInternal::ThreadPool::run() _threadMutex.unlock(); throw SocketException(__FILE__, __LINE__); } - + { JTCSyncT<JTCMonitorT<JTCMutex> > sync(*this); diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index 71983722237..fb3e76baca7 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -56,6 +56,7 @@ private: std::vector<int> _removes; std::map<int, EventHandlerPtr> _handlers; int _servers; + int _timeout; JTCMutex _threadMutex; class EventHandlerThread : public JTCThread |