From 8bccaa84b6b2c204608af57e1710028b7d71ff3f Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Tue, 16 Jan 2007 10:37:23 +0000 Subject: http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1179 --- cpp/src/Ice/ThreadPool.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'cpp/src/Ice/ThreadPool.cpp') diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 5b16ee748eb..5240889b537 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -60,6 +60,7 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p _minFd = _fdIntrRead; #if defined(_WIN32) + _fdsInUse = 1; // _fdIntrRead is always in use. FD_ZERO(&_fdSet); FD_SET(_fdIntrRead, &_fdSet); #elif defined(__linux) @@ -209,6 +210,48 @@ IceInternal::ThreadPool::destroy() setInterrupt(); } +void +IceInternal::ThreadPool::incFdsInUse() +{ + // This is windows specific since every other platform uses an API + // that doesn't have a specific FD limit. +#ifdef _WIN32 + IceUtil::Monitor::Lock sync(*this); + assert(!_destroyed); + if(_fdsInUse + 1 > FD_SETSIZE) + { + Warning warn(_instance->initializationData().logger); + warn << "maximum number of connections exceeded"; + + // + // No appropriate errno. + // + SocketException ex(__FILE__, __LINE__); + ex.error = 0; + throw ex; + } + ++_fdsInUse; +#endif +} + +void +IceInternal::ThreadPool::decFdsInUse() +{ + // This is windows specific since every other platform uses an API + // that doesn't have a specific FD limit. +#ifdef _WIN32 + IceUtil::Monitor::Lock sync(*this); + assert(!_destroyed); + if(_fdsInUse <= 1) + { + Trace trace(_instance->initializationData().logger, "ThreadPool"); + trace << _prefix << ": about to assert"; + } + assert(_fdsInUse > 1); // _fdIntrRead is always in use. + --_fdsInUse; +#endif +} + void IceInternal::ThreadPool::_register(SOCKET fd, const EventHandlerPtr& handler) { -- cgit v1.2.3