diff options
author | Marc Laukien <marc@zeroc.com> | 2001-08-22 20:52:13 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-08-22 20:52:13 +0000 |
commit | 611da271dc12cc6517267ed8d6d553805cb16d9f (patch) | |
tree | 645a092bd25b17819a688dcb8fa81c897fcc7039 /cpp/src/Ice/ThreadPool.cpp | |
parent | SysLogger (diff) | |
download | ice-611da271dc12cc6517267ed8d6d553805cb16d9f.tar.bz2 ice-611da271dc12cc6517267ed8d6d553805cb16d9f.tar.xz ice-611da271dc12cc6517267ed8d6d553805cb16d9f.zip |
lots of stuff
Diffstat (limited to 'cpp/src/Ice/ThreadPool.cpp')
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
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); |