diff options
author | Matthew Newhook <matthew@zeroc.com> | 2007-01-16 10:37:23 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2007-01-16 10:37:23 +0000 |
commit | 8bccaa84b6b2c204608af57e1710028b7d71ff3f (patch) | |
tree | d2385d8753ceb677110d6d8c508a1bac837ef486 /cpp/src/Ice/ThreadPool.cpp | |
parent | http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1665 (diff) | |
download | ice-8bccaa84b6b2c204608af57e1710028b7d71ff3f.tar.bz2 ice-8bccaa84b6b2c204608af57e1710028b7d71ff3f.tar.xz ice-8bccaa84b6b2c204608af57e1710028b7d71ff3f.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1179
Diffstat (limited to 'cpp/src/Ice/ThreadPool.cpp')
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
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) @@ -210,6 +211,48 @@ IceInternal::ThreadPool::destroy() } 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<IceUtil::Mutex>::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<IceUtil::Mutex>::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) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); |