summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/Acceptor.h1
-rw-r--r--cpp/src/Ice/ConfigParser.cpp24
-rw-r--r--cpp/src/Ice/ConfigParserErrorReporter.cpp32
-rw-r--r--cpp/src/Ice/Connection.cpp17
-rw-r--r--cpp/src/Ice/Connection.h2
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp76
-rw-r--r--cpp/src/Ice/ConnectionFactory.h2
-rw-r--r--cpp/src/Ice/ContextOpenSSL.cpp36
-rw-r--r--cpp/src/Ice/ContextOpenSSLClient.cpp10
-rw-r--r--cpp/src/Ice/ContextOpenSSLServer.cpp10
-rw-r--r--cpp/src/Ice/EventHandler.h10
-rw-r--r--cpp/src/Ice/RSACertificateGen.cpp8
-rw-r--r--cpp/src/Ice/RSAPrivateKey.cpp7
-rw-r--r--cpp/src/Ice/RSAPublicKey.cpp2
-rw-r--r--cpp/src/Ice/SslAcceptor.cpp13
-rw-r--r--cpp/src/Ice/SslAcceptor.h1
-rw-r--r--cpp/src/Ice/SslConnectionOpenSSL.cpp16
-rw-r--r--cpp/src/Ice/SslConnectionOpenSSLClient.cpp10
-rw-r--r--cpp/src/Ice/SslConnectionOpenSSLServer.cpp12
-rw-r--r--cpp/src/Ice/SslTransceiver.cpp2
-rw-r--r--cpp/src/Ice/SystemOpenSSL.cpp17
-rw-r--r--cpp/src/Ice/TcpAcceptor.cpp12
-rw-r--r--cpp/src/Ice/TcpAcceptor.h1
-rw-r--r--cpp/src/Ice/ThreadPool.cpp252
-rw-r--r--cpp/src/Ice/ThreadPool.h4
25 files changed, 286 insertions, 291 deletions
diff --git a/cpp/src/Ice/Acceptor.h b/cpp/src/Ice/Acceptor.h
index 1387312aa88..8833be76af1 100644
--- a/cpp/src/Ice/Acceptor.h
+++ b/cpp/src/Ice/Acceptor.h
@@ -28,7 +28,6 @@ public:
virtual SOCKET fd() = 0;
virtual void close() = 0;
- virtual void shutdown() = 0;
virtual void listen() = 0;
virtual TransceiverPtr accept(int) = 0;
virtual std::string toString() const = 0;
diff --git a/cpp/src/Ice/ConfigParser.cpp b/cpp/src/Ice/ConfigParser.cpp
index 360a01ef215..f2bd2df16fb 100644
--- a/cpp/src/Ice/ConfigParser.cpp
+++ b/cpp/src/Ice/ConfigParser.cpp
@@ -74,8 +74,8 @@ IceSSL::ConfigParser::process()
ConfigParseException configEx(__FILE__, __LINE__);
ostringstream s;
- s << "While parsing " << _configFile << ": " << endl;
- s << "Xerces-c Init Exception: " << DOMString(toCatch.getMessage());
+ s << "while parsing " << _configFile << ": " << endl;
+ s << "xerces-c init exception: " << DOMString(toCatch.getMessage());
configEx._message = s.str();
@@ -137,8 +137,8 @@ IceSSL::ConfigParser::process()
ConfigParseException configEx(__FILE__, __LINE__);
ostringstream s;
- s << "While parsing " << _configFile << ": " << endl;
- s << "Xerces-c Parsing Error: " << DOMString(e.getMessage());
+ s << "while parsing " << _configFile << ": " << endl;
+ s << "xerces-c parsing error: " << DOMString(e.getMessage());
configEx._message = s.str();
@@ -149,8 +149,8 @@ IceSSL::ConfigParser::process()
ConfigParseException configEx(__FILE__, __LINE__);
ostringstream s;
- s << "While parsing " << _configFile << ": " << endl;
- s << "Xerces-c DOM Parsing Error, DOMException code: " << e.code;
+ s << "while parsing " << _configFile << ": " << endl;
+ s << "xerces-c DOM parsing error, DOMException code: " << e.code;
s << ", message: " << e.msg;
configEx._message = s.str();
@@ -161,7 +161,7 @@ IceSSL::ConfigParser::process()
{
ConfigParseException configEx(__FILE__, __LINE__);
- configEx._message = "While parsing " + _configFile + "\n" + "An unknown error occured during parsing.";
+ configEx._message = "while parsing " + _configFile + "\n" + "unknown error occured during parsing";
throw configEx;
}
@@ -172,7 +172,7 @@ IceSSL::ConfigParser::process()
ostringstream errStr;
- errStr << dec << errorCount << " errors occured during parsing.";
+ errStr << dec << errorCount << " errors occured during parsing";
configEx._message = errStr.str();
@@ -204,8 +204,8 @@ IceSSL::ConfigParser::loadClientConfig(GeneralConfig& general,
ConfigParseException configEx(__FILE__, __LINE__);
ostringstream s;
- s << "While loading Client configuration: " << endl;
- s << "Xerces-c DOM Parsing Error, DOMException code: " << e.code;
+ s << "while loading client configuration: " << endl;
+ s << "xerces-c DOM parsing error, DOMException code: " << e.code;
s << ", message: " << e.msg;
configEx._message = s.str();
@@ -242,8 +242,8 @@ IceSSL::ConfigParser::loadServerConfig(GeneralConfig& general,
ConfigParseException configEx(__FILE__, __LINE__);
ostringstream s;
- s << "While loading Server configuration " << endl;
- s << "Xerces-c DOM Parsing Error, DOMException code: " << e.code;
+ s << "while loading server configuration " << endl;
+ s << "xerces-c DOM parsing error, DOMException code: " << e.code;
s << ", message: " << e.msg;
configEx._message = s.str();
diff --git a/cpp/src/Ice/ConfigParserErrorReporter.cpp b/cpp/src/Ice/ConfigParserErrorReporter.cpp
index fdbe17eebd3..f9e4d684901 100644
--- a/cpp/src/Ice/ConfigParserErrorReporter.cpp
+++ b/cpp/src/Ice/ConfigParserErrorReporter.cpp
@@ -43,12 +43,10 @@ IceSSL::ConfigParserErrorReporter::warning(const SAXParseException& toCatch)
{
ostringstream s;
- s << "SSL configuration file parse warning." << endl;
- s << "Xerces-c Init Exception: Warning at file \"" << flush;
- s << DOMString(toCatch.getSystemId()) << flush;
- s << "\", line " << toCatch.getLineNumber() << flush;
- s << ", column " << toCatch.getColumnNumber() << flush;
- s << "\n Message: " << DOMString(toCatch.getMessage()) << endl;
+ s << "ssl configuration file parse warning\n";
+ s << "xerces-c init exception: warning at file \"" << DOMString(toCatch.getSystemId())
+ << "\", line " << toCatch.getLineNumber() << ", column " << toCatch.getColumnNumber() << '\n';
+ s << "message: " << DOMString(toCatch.getMessage());
_logger->trace(_traceLevels->securityCat, "PWN " + s.str());
}
@@ -63,13 +61,11 @@ IceSSL::ConfigParserErrorReporter::error(const SAXParseException& toCatch)
{
ostringstream s;
- s << "SSL configuration file parse error." << endl;
- s << "Xerces-c Init Exception: Error at file \"" << flush;
- s << DOMString(toCatch.getSystemId()) << flush;
- s << "\", line " << toCatch.getLineNumber() << flush;
- s << ", column " << toCatch.getColumnNumber() << flush;
- s << "\n Message: " << DOMString(toCatch.getMessage()) << endl;
-
+ s << "ssl configuration file parse error\n";
+ s << "xerces-c init exception: error at file \"" << DOMString(toCatch.getSystemId())
+ << "\", line " << toCatch.getLineNumber() << ", column " << toCatch.getColumnNumber() << '\n';
+ s << "message: " << DOMString(toCatch.getMessage());
+
_logger->trace(_traceLevels->securityCat, "PWN " + s.str());
}
}
@@ -83,12 +79,10 @@ IceSSL::ConfigParserErrorReporter::fatalError(const SAXParseException& toCatch)
{
ostringstream s;
- s << "SSL configuration file parse error." << endl;
- s << "Xerces-c Init Exception: Fatal error at file \"" << flush;
- s << DOMString(toCatch.getSystemId()) << flush;
- s << "\", line " << toCatch.getLineNumber() << flush;
- s << ", column " << toCatch.getColumnNumber() << flush;
- s << "\n Message: " << DOMString(toCatch.getMessage()) << endl;
+ s << "ssl configuration file parse error\n";
+ s << "xerces-c init exception: fatal error at file \"" << DOMString(toCatch.getSystemId())
+ << "\", line " << toCatch.getLineNumber() << ", column " << toCatch.getColumnNumber() << '\n';
+ s << "message: " << DOMString(toCatch.getMessage()) << endl;
_logger->trace(_traceLevels->securityCat, "PWN " + s.str());
}
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index 8dda6a9abb0..01ecb5fe6e5 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -293,11 +293,10 @@ IceInternal::Connection::message(BasicStream& stream)
if (_state == StateClosed)
{
- ::IceUtil::ThreadControl::yield();
+ IceUtil::ThreadControl::yield();
return;
}
-
Byte messageType;
try
@@ -535,18 +534,22 @@ IceInternal::Connection::message(BasicStream& stream)
}
void
-IceInternal::Connection::exception(const LocalException& ex)
+IceInternal::Connection::finished()
{
IceUtil::RecMutex::Lock sync(*this);
- setState(StateClosed, ex);
+
+ _threadPool->promoteFollower();
+
+ assert(_state == StateClosed);
+
+ _transceiver->close();
}
void
-IceInternal::Connection::finished()
+IceInternal::Connection::exception(const LocalException& ex)
{
IceUtil::RecMutex::Lock sync(*this);
- assert(_state == StateClosed);
- _transceiver->close();
+ setState(StateClosed, ex);
}
/*
diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h
index 8f94ad2231b..18f95a38230 100644
--- a/cpp/src/Ice/Connection.h
+++ b/cpp/src/Ice/Connection.h
@@ -64,8 +64,8 @@ public:
virtual bool readable() const;
virtual void read(BasicStream&);
virtual void message(BasicStream&);
- virtual void exception(const ::Ice::LocalException&);
virtual void finished();
+ virtual void exception(const ::Ice::LocalException&);
private:
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index 0053152b5b0..378ce96d84a 100644
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -304,9 +304,10 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&)
{
IceUtil::Mutex::Lock sync(*this);
+ _threadPool->promoteFollower();
+
if (_state != StateActive)
{
- _threadPool->promoteFollower();
IceUtil::ThreadControl::yield();
return;
}
@@ -350,14 +351,6 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&)
}
setState(StateClosed);
}
-
- _threadPool->promoteFollower();
-}
-
-void
-IceInternal::IncomingConnectionFactory::exception(const LocalException&)
-{
- assert(false); // Must not be called.
}
void
@@ -365,41 +358,49 @@ IceInternal::IncomingConnectionFactory::finished()
{
IceUtil::Mutex::Lock sync(*this);
- assert(_state == StateClosed);
-
- _acceptor->shutdown();
+ _threadPool->promoteFollower();
-#ifdef _STLP_BEGIN_NAMESPACE
- // voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h
- for_each(_connections.begin(), _connections.end(),
- voidbind2nd(Ice::voidMemFun1(&Connection::destroy), Connection::ObjectAdapterDeactivated));
-#else
- for_each(_connections.begin(), _connections.end(),
- bind2nd(Ice::voidMemFun1(&Connection::destroy), Connection::ObjectAdapterDeactivated));
-#endif
- _connections.clear();
+ assert(_state == StateClosed);
+ assert(_connections.empty());
- //
- // Clear listen() backlog properly by accepting all queued
- // connections, and then shutting them down.
- //
- while (true)
+ try
{
- try
+ //
+ // Clear listen() backlog properly by accepting all queued
+ // connections, and then shutting them down.
+ //
+ while (true)
{
- TransceiverPtr transceiver = _acceptor->accept(0);
- ConnectionPtr connection = new Connection(_instance, transceiver, _endpoint, _adapter);
- connection->exception(ObjectAdapterDeactivatedException(__FILE__, __LINE__));
+ try
+ {
+ TransceiverPtr transceiver = _acceptor->accept(0);
+ ConnectionPtr connection = new Connection(_instance, transceiver, _endpoint, _adapter);
+ connection->exception(ObjectAdapterDeactivatedException(__FILE__, __LINE__));
+ }
+ catch (const TimeoutException&)
+ {
+ break; // Exit loop on timeout.
+ }
}
- catch (const Exception&)
+ }
+ catch (const LocalException& ex)
+ {
+ if (_warn)
{
- break;
+ Warning out(_instance->logger());
+ out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
}
}
_acceptor->close();
}
+void
+IceInternal::IncomingConnectionFactory::exception(const LocalException&)
+{
+ assert(false); // Must not be called.
+}
+
/*
bool
IceInternal::IncomingConnectionFactory::tryDestroy()
@@ -513,6 +514,17 @@ IceInternal::IncomingConnectionFactory::setState(State state)
}
_threadPool->unregister(_acceptor->fd(), true);
}
+
+#ifdef _STLP_BEGIN_NAMESPACE
+ // voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h
+ for_each(_connections.begin(), _connections.end(),
+ voidbind2nd(Ice::voidMemFun1(&Connection::destroy), Connection::ObjectAdapterDeactivated));
+#else
+ for_each(_connections.begin(), _connections.end(),
+ bind2nd(Ice::voidMemFun1(&Connection::destroy), Connection::ObjectAdapterDeactivated));
+#endif
+ _connections.clear();
+
break;
}
}
diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h
index 533c55b3abf..7b962c895cb 100644
--- a/cpp/src/Ice/ConnectionFactory.h
+++ b/cpp/src/Ice/ConnectionFactory.h
@@ -71,8 +71,8 @@ public:
virtual bool readable() const;
virtual void read(BasicStream&);
virtual void message(BasicStream&);
- virtual void exception(const ::Ice::LocalException&);
virtual void finished();
+ virtual void exception(const ::Ice::LocalException&);
private:
diff --git a/cpp/src/Ice/ContextOpenSSL.cpp b/cpp/src/Ice/ContextOpenSSL.cpp
index 35204470657..3275f65d432 100644
--- a/cpp/src/Ice/ContextOpenSSL.cpp
+++ b/cpp/src/Ice/ContextOpenSSL.cpp
@@ -162,9 +162,9 @@ IceSSL::OpenSSL::Context::getSslMethod(SslProtocol sslVersion)
{
std::string errorString;
- errorString = "SSL Version ";
+ errorString = "ssl version ";
errorString += sslVersion;
- errorString += " not supported - defaulting to SSL_V23.";
+ errorString += " not supported (defaulting to SSL_V23)";
_logger->trace(_traceLevels->securityCat, "WRN " + errorString);
}
@@ -190,7 +190,7 @@ IceSSL::OpenSSL::Context::createContext(SslProtocol sslProtocol)
{
IceSSL::OpenSSL::ContextInitializationException contextInitEx(__FILE__, __LINE__);
- contextInitEx._message = "Unable to create SSL Context.\n" + sslGetErrors();
+ contextInitEx._message = "unable to create ssl context\n" + sslGetErrors();
throw contextInitEx;
}
@@ -232,7 +232,7 @@ IceSSL::OpenSSL::Context::loadCertificateAuthority(const CertificateAuthority& c
{
if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)
{
- _logger->trace(_traceLevels->securityCat, "WRN Unable to load Certificate Authorities.");
+ _logger->trace(_traceLevels->securityCat, "WRN unable to load certificate authorities.");
}
}
else
@@ -242,7 +242,7 @@ IceSSL::OpenSSL::Context::loadCertificateAuthority(const CertificateAuthority& c
if (!setDefaultVerifyPathsRet && (_traceLevels->security >= IceSSL::SECURITY_WARNINGS))
{
- _logger->trace(_traceLevels->securityCat, "WRN Unable to verify Certificate Authorities.");
+ _logger->trace(_traceLevels->securityCat, "WRN unable to verify certificate authorities.");
}
}
@@ -296,7 +296,7 @@ IceSSL::OpenSSL::Context::checkKeyCert()
{
IceSSL::OpenSSL::CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__);
- certKeyMatchEx._message = "Private key does not match the certificate public key.";
+ certKeyMatchEx._message = "private key does not match the certificate public key";
std::string sslError = sslGetErrors();
if (!sslError.empty())
@@ -316,7 +316,7 @@ IceSSL::OpenSSL::Context::addTrustedCertificate(const RSAPublicKey& trustedCerti
{
IceSSL::OpenSSL::ContextNotConfiguredException contextConfigEx(__FILE__, __LINE__);
- contextConfigEx._message = "SSL Context not configured.";
+ contextConfigEx._message = "ssl context not configured";
throw contextConfigEx;
}
@@ -355,7 +355,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce
{
IceSSL::OpenSSL::CertificateLoadException certLoadEx(__FILE__, __LINE__);
- certLoadEx._message = "Unable to load certificate from '";
+ certLoadEx._message = "unable to load certificate from '";
certLoadEx._message += publicFile;
certLoadEx._message += "'\n";
certLoadEx._message += sslGetErrors();
@@ -367,7 +367,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce
{
if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)
{
- _logger->trace(_traceLevels->securityCat, "WRN No private key specified - using the certificate.");
+ _logger->trace(_traceLevels->securityCat, "WRN no private key specified -- using the certificate");
}
privKeyFile = publicFile;
@@ -385,7 +385,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce
{
IceSSL::OpenSSL::CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__);
- certKeyMatchEx._message = "Private key does not match the certificate public key.";
+ certKeyMatchEx._message = "private key does not match the certificate public key";
std::string sslError = sslGetErrors();
if (!sslError.empty())
@@ -400,7 +400,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce
{
IceSSL::OpenSSL::PrivateKeyLoadException pklEx(__FILE__, __LINE__);
- pklEx._message = "Unable to load private key from '";
+ pklEx._message = "unable to load private key from '";
pklEx._message += privKeyFile;
pklEx._message += "'\n";
pklEx._message += sslGetErrors();
@@ -420,7 +420,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair)
{
IceSSL::OpenSSL::ContextNotConfiguredException contextConfigEx(__FILE__, __LINE__);
- contextConfigEx._message = "SSL Context not configured.";
+ contextConfigEx._message = "ssl context not configured";
throw contextConfigEx;
}
@@ -435,7 +435,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair)
{
IceSSL::OpenSSL::CertificateLoadException certLoadEx(__FILE__, __LINE__);
- certLoadEx._message = "Unable to set certificate from memory.";
+ certLoadEx._message = "unable to set certificate from memory";
std::string sslError = sslGetErrors();
if (!sslError.empty())
@@ -458,7 +458,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair)
{
IceSSL::OpenSSL::CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__);
- certKeyMatchEx._message = "Private key does not match the certificate public key.";
+ certKeyMatchEx._message = "private key does not match the certificate public key";
std::string sslError = sslGetErrors();
if (!sslError.empty())
@@ -473,7 +473,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair)
{
IceSSL::OpenSSL::PrivateKeyLoadException pklEx(__FILE__, __LINE__);
- pklEx._message = "Unable to set private key from memory.";
+ pklEx._message = "unable to set private key from memory";
std::string sslError = sslGetErrors();
if (!sslError.empty())
@@ -498,7 +498,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const Ice::ByteSeq& privateKey, const Ice::
{
if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)
{
- _logger->trace(_traceLevels->securityCat, "WRN No private key specified - using the certificate.");
+ _logger->trace(_traceLevels->securityCat, "WRN no private key specified -- using the certificate");
}
privKey = publicKey;
@@ -517,7 +517,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const std::string& privateKey, const std::s
{
if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)
{
- _logger->trace(_traceLevels->securityCat, "WRN No private key specified - using the certificate.");
+ _logger->trace(_traceLevels->securityCat, "WRN no private key specified -- using the certificate");
}
privKey = publicKey;
@@ -570,7 +570,7 @@ IceSSL::OpenSSL::Context::setCipherList(const std::string& cipherList)
if (!cipherList.empty() && (!SSL_CTX_set_cipher_list(_sslContext, cipherList.c_str())) &&
(_traceLevels->security >= IceSSL::SECURITY_WARNINGS))
{
- std::string errorString = "WRN Error setting cipher list " + cipherList + " - using default list.\n";
+ std::string errorString = "WRN error setting cipher list " + cipherList + " -- using default list\n";
errorString += sslGetErrors();
_logger->trace(_traceLevels->securityCat, errorString);
}
diff --git a/cpp/src/Ice/ContextOpenSSLClient.cpp b/cpp/src/Ice/ContextOpenSSLClient.cpp
index 50f75ce73b2..3689f00151b 100644
--- a/cpp/src/Ice/ContextOpenSSLClient.cpp
+++ b/cpp/src/Ice/ContextOpenSSLClient.cpp
@@ -35,16 +35,16 @@ IceSSL::OpenSSL::ClientContext::configure(const GeneralConfig& generalConfig,
std::ostringstream s;
s << std::endl;
- s << "General Configuration - Client" << std::endl;
+ s << "general configuration (client)" << std::endl;
s << "------------------------------" << std::endl;
s << generalConfig << std::endl << std::endl;
- s << "Certificate Authority - Client" << std::endl;
+ s << "certificate authority (client)" << std::endl;
s << "------------------------------" << std::endl;
- s << "File: " << certificateAuthority.getCAFileName() << std::endl;
- s << "Path: " << certificateAuthority.getCAPath() << std::endl;
+ s << "file: " << certificateAuthority.getCAFileName() << std::endl;
+ s << "path: " << certificateAuthority.getCAPath() << std::endl;
- s << "Base Certificates - Client" << std::endl;
+ s << "base certificates (client)" << std::endl;
s << "--------------------------" << std::endl;
s << baseCertificates << std::endl;
diff --git a/cpp/src/Ice/ContextOpenSSLServer.cpp b/cpp/src/Ice/ContextOpenSSLServer.cpp
index c24f65be92a..97775069a12 100644
--- a/cpp/src/Ice/ContextOpenSSLServer.cpp
+++ b/cpp/src/Ice/ContextOpenSSLServer.cpp
@@ -58,14 +58,14 @@ IceSSL::OpenSSL::ServerContext::configure(const GeneralConfig& generalConfig,
std::ostringstream s;
s << std::endl;
- s << "General Configuration - Server" << std::endl;
+ s << "general configuration (server)" << std::endl;
s << "------------------------------" << std::endl;
s << generalConfig << std::endl << std::endl;
- s << "CA File: " << certificateAuthority.getCAFileName() << std::endl;
- s << "CA Path: " << certificateAuthority.getCAPath() << std::endl;
+ s << "CA file: " << certificateAuthority.getCAFileName() << std::endl;
+ s << "CA path: " << certificateAuthority.getCAPath() << std::endl;
- s << "Base Certificates - Server" << std::endl;
+ s << "base certificates (server)" << std::endl;
s << "--------------------------" << std::endl;
s << baseCertificates << std::endl << std::endl;
@@ -129,7 +129,7 @@ IceSSL::OpenSSL::ServerContext::loadCertificateAuthority(const CertificateAuthor
{
if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)
{
- std::string errorString = "Unable to load Certificate Authorities certificate names from " + caFile + ".\n";
+ std::string errorString = "unable to load certificate authorities certificate names from " + caFile + "\n";
errorString += sslGetErrors();
_logger->trace(_traceLevels->securityCat, "WRN " + errorString);
}
diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h
index c7bcb44cdd8..4d5434b579c 100644
--- a/cpp/src/Ice/EventHandler.h
+++ b/cpp/src/Ice/EventHandler.h
@@ -54,11 +54,6 @@ public:
virtual void message(BasicStream&) = 0;
//
- // Propagate an exception to the event handler.
- //
- virtual void exception(const ::Ice::LocalException&) = 0;
-
- //
// Will be called if the event handler is finally
// unregistered. (Calling unregister() does not unregister
// immediately.)
@@ -66,6 +61,11 @@ public:
virtual void finished() = 0;
//
+ // Propagate an exception to the event handler.
+ //
+ virtual void exception(const ::Ice::LocalException&) = 0;
+
+ //
// Try to destroy the event handler. Returns false if the event
// handler cannot be destroyed because it is in use, or true
// otherwise.
diff --git a/cpp/src/Ice/RSACertificateGen.cpp b/cpp/src/Ice/RSACertificateGen.cpp
index 59efe44af32..379b5f5a1b5 100644
--- a/cpp/src/Ice/RSACertificateGen.cpp
+++ b/cpp/src/Ice/RSACertificateGen.cpp
@@ -287,7 +287,7 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons
{
IceSSL::OpenSSL::CertificateLoadException certLoadEx(__FILE__, __LINE__);
- certLoadEx._message = "Unable to load certificate from '";
+ certLoadEx._message = "unable to load certificate from '";
certLoadEx._message += certFile;
certLoadEx._message += "'\n";
certLoadEx._message += sslGetErrors();
@@ -301,7 +301,7 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons
{
IceSSL::OpenSSL::CertificateLoadException certLoadEx(__FILE__, __LINE__);
- certLoadEx._message = "Unable to load certificate from '";
+ certLoadEx._message = "unable to load certificate from '";
certLoadEx._message += certFile;
certLoadEx._message += "'\n";
certLoadEx._message += sslGetErrors();
@@ -317,7 +317,7 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons
{
IceSSL::OpenSSL::PrivateKeyLoadException pklEx(__FILE__, __LINE__);
- pklEx._message = "Unable to load private key from '";
+ pklEx._message = "unable to load private key from '";
pklEx._message += keyFile;
pklEx._message += "'\n";
pklEx._message += sslGetErrors();
@@ -331,7 +331,7 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons
{
IceSSL::OpenSSL::PrivateKeyLoadException pklEx(__FILE__, __LINE__);
- pklEx._message = "Unable to load private key from '";
+ pklEx._message = "unable to load private key from '";
pklEx._message += keyFile;
pklEx._message += "'\n";
pklEx._message += sslGetErrors();
diff --git a/cpp/src/Ice/RSAPrivateKey.cpp b/cpp/src/Ice/RSAPrivateKey.cpp
index f91d1cd4d94..d099ede789f 100644
--- a/cpp/src/Ice/RSAPrivateKey.cpp
+++ b/cpp/src/Ice/RSAPrivateKey.cpp
@@ -85,7 +85,7 @@ IceSSL::OpenSSL::RSAPrivateKey::keyToByteSeq(ByteSeq& keySeq)
IceSSL::ucharToByteSeq(privateKeyBuffer, privKeySize, keySeq);
- delete []privateKeyBuffer;
+ delete [] privateKeyBuffer;
}
RSA*
@@ -110,11 +110,12 @@ IceSSL::OpenSSL::RSAPrivateKey::byteSeqToKey(const ByteSeq& keySeq)
{
IceSSL::PrivateKeyParseException pkParseException(__FILE__, __LINE__);
- pkParseException._message = "Unable to parse provided Private Key.\n" + sslGetErrors();
+ pkParseException._message = "unable to parse provided private key\n" + sslGetErrors();
throw pkParseException;
}
- delete []privateKeyBuffer;
+ // ML: Not deleted if an exception is raised!
+ delete [] privateKeyBuffer;
}
diff --git a/cpp/src/Ice/RSAPublicKey.cpp b/cpp/src/Ice/RSAPublicKey.cpp
index 321e56d3c34..f40076d8111 100644
--- a/cpp/src/Ice/RSAPublicKey.cpp
+++ b/cpp/src/Ice/RSAPublicKey.cpp
@@ -111,7 +111,7 @@ IceSSL::OpenSSL::RSAPublicKey::byteSeqToCert(const ByteSeq& certSeq)
{
IceSSL::CertificateParseException certParseException(__FILE__, __LINE__);
- certParseException._message = "Unable to parse provided Public Key.\n" + sslGetErrors();
+ certParseException._message = "unable to parse provided public key\n" + sslGetErrors();
throw certParseException;
}
diff --git a/cpp/src/Ice/SslAcceptor.cpp b/cpp/src/Ice/SslAcceptor.cpp
index 4d7aadd8eee..89db1f4e44c 100644
--- a/cpp/src/Ice/SslAcceptor.cpp
+++ b/cpp/src/Ice/SslAcceptor.cpp
@@ -60,19 +60,6 @@ IceInternal::SslAcceptor::close()
}
void
-IceInternal::SslAcceptor::shutdown()
-{
- if (_traceLevels->network >= 2)
- {
- ostringstream s;
- s << "shutting down accepting ssl connections at " << toString();
- _logger->trace(_traceLevels->networkCat, s.str());
- }
-
- ::shutdown(_fd, SHUT_RD); // Shutdown socket for reading
-}
-
-void
IceInternal::SslAcceptor::listen()
{
try
diff --git a/cpp/src/Ice/SslAcceptor.h b/cpp/src/Ice/SslAcceptor.h
index fa11f996c33..17ceaddf8e7 100644
--- a/cpp/src/Ice/SslAcceptor.h
+++ b/cpp/src/Ice/SslAcceptor.h
@@ -32,7 +32,6 @@ public:
virtual SOCKET fd();
virtual void close();
- virtual void shutdown();
virtual void listen();
virtual TransceiverPtr accept(int);
virtual std::string toString() const;
diff --git a/cpp/src/Ice/SslConnectionOpenSSL.cpp b/cpp/src/Ice/SslConnectionOpenSSL.cpp
index 7aa05a185f7..289015b64a1 100644
--- a/cpp/src/Ice/SslConnectionOpenSSL.cpp
+++ b/cpp/src/Ice/SslConnectionOpenSSL.cpp
@@ -116,7 +116,7 @@ IceSSL::OpenSSL::Connection::shutdown()
if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)
{
_logger->trace(_traceLevels->securityCat, "WRN " +
- string("shutting down SSL connection\n") +
+ string("shutting down ssl connection\n") +
fdToString(SSL_get_fd(_sslConnection)));
}
@@ -134,7 +134,7 @@ IceSSL::OpenSSL::Connection::shutdown()
if ((_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) && (shutdown <= 0))
{
ostringstream s;
- s << "SSL shutdown failure encountered: code[" << shutdown << "] retries[";
+ s << "ssl shutdown failure encountered: code[" << shutdown << "] retries[";
s << (retries + numRetries) << "]\n" << fdToString(SSL_get_fd(_sslConnection));
_logger->trace(_traceLevels->securityCat, s.str());
}
@@ -190,7 +190,7 @@ IceSSL::OpenSSL::Connection::verifyCertificate(int preVerifyOkay, X509_STORE_CTX
{
ostringstream s;
- s << "WRN Exception during certificate verification: " << std::endl;
+ s << "WRN exception during certificate verification: " << std::endl;
s << localEx << flush;
_logger->trace(_traceLevels->securityCat, s.str());
@@ -210,12 +210,12 @@ IceSSL::OpenSSL::Connection::verifyCertificate(int preVerifyOkay, X509_STORE_CTX
if (_certificateVerifier.get())
{
- errorString = "WRN Improper CertificateVerifier type.";
+ errorString = "WRN improper CertificateVerifier type";
}
else
{
// NOTE: This should NEVER be able to happen, but just in case.
- errorString = "WRN CertificateVerifier not set.";
+ errorString = "WRN CertificateVerifier not set";
}
_logger->trace(_traceLevels->securityCat, errorString);
@@ -460,7 +460,7 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout)
{
if (_traceLevels->security >= IceSSL::SECURITY_PROTOCOL)
{
- _logger->trace(_traceLevels->securityCat, "No pending application-level bytes.");
+ _logger->trace(_traceLevels->securityCat, "no pending application-level bytes");
}
// We're done here.
@@ -537,7 +537,7 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout)
ProtocolException protocolEx(__FILE__, __LINE__);
// Protocol Error: Unexpected EOF
- protocolEx._message = "Encountered an EOF that violates the SSL Protocol.\n";
+ protocolEx._message = "encountered an EOF that violates the ssl protocol\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
@@ -548,7 +548,7 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout)
{
ProtocolException protocolEx(__FILE__, __LINE__);
- protocolEx._message = "Encountered a violation of the SSL Protocol.\n";
+ protocolEx._message = "encountered a violation of the ssl protocol\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
diff --git a/cpp/src/Ice/SslConnectionOpenSSLClient.cpp b/cpp/src/Ice/SslConnectionOpenSSLClient.cpp
index 328d9d6a5e1..b07b9566b71 100644
--- a/cpp/src/Ice/SslConnectionOpenSSLClient.cpp
+++ b/cpp/src/Ice/SslConnectionOpenSSLClient.cpp
@@ -167,7 +167,7 @@ IceSSL::OpenSSL::ClientConnection::init(int timeout)
ProtocolException protocolEx(__FILE__, __LINE__);
// Protocol Error: Unexpected EOF
- protocolEx._message = "Encountered an EOF during handshake that violates the SSL Protocol.\n";
+ protocolEx._message = "encountered an EOF during handshake that violates the ssl protocol\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
@@ -182,7 +182,7 @@ IceSSL::OpenSSL::ClientConnection::init(int timeout)
{
CertificateVerificationException certVerEx(__FILE__, __LINE__);
- certVerEx._message = "SSL certificate verification error.";
+ certVerEx._message = "ssl certificate verification error";
string errors = sslGetErrors();
@@ -198,7 +198,7 @@ IceSSL::OpenSSL::ClientConnection::init(int timeout)
{
ProtocolException protocolEx(__FILE__, __LINE__);
- protocolEx._message = "Encountered a violation of the SSL Protocol during handshake.\n";
+ protocolEx._message = "encountered a violation of the ssl protocol during handshake\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
@@ -331,7 +331,7 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout)
ProtocolException protocolEx(__FILE__, __LINE__);
// Protocol Error: Unexpected EOF
- protocolEx._message = "Encountered an EOF that violates the SSL Protocol.\n";
+ protocolEx._message = "encountered an EOF that violates the ssl protocol\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
@@ -347,7 +347,7 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout)
{
ProtocolException protocolEx(__FILE__, __LINE__);
- protocolEx._message = "Encountered a violation of the SSL Protocol.\n";
+ protocolEx._message = "encountered a violation of the ssl protocol\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
diff --git a/cpp/src/Ice/SslConnectionOpenSSLServer.cpp b/cpp/src/Ice/SslConnectionOpenSSLServer.cpp
index 78f13d0bbd1..a86f18edede 100644
--- a/cpp/src/Ice/SslConnectionOpenSSLServer.cpp
+++ b/cpp/src/Ice/SslConnectionOpenSSLServer.cpp
@@ -118,7 +118,7 @@ IceSSL::OpenSSL::ServerConnection::init(int timeout)
{
CertificateVerificationException certVerEx(__FILE__, __LINE__);
- certVerEx._message = "SSL certificate verification error.";
+ certVerEx._message = "ssl certificate verification error";
string errors = sslGetErrors();
@@ -134,7 +134,7 @@ IceSSL::OpenSSL::ServerConnection::init(int timeout)
{
ProtocolException protocolEx(__FILE__, __LINE__);
- protocolEx._message = "Encountered an SSL Protocol violation during handshake.\n";
+ protocolEx._message = "encountered an ssl protocol violation during handshake\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
@@ -200,7 +200,7 @@ IceSSL::OpenSSL::ServerConnection::init(int timeout)
ProtocolException protocolEx(__FILE__, __LINE__);
// Protocol Error: Unexpected EOF
- protocolEx._message = "Encountered an EOF during handshake that violates the SSL Protocol.\n";
+ protocolEx._message = "encountered an eof during handshake that violates the ssl protocol\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
@@ -211,7 +211,7 @@ IceSSL::OpenSSL::ServerConnection::init(int timeout)
{
ProtocolException protocolEx(__FILE__, __LINE__);
- protocolEx._message = "Encountered a violation of the SSL Protocol during handshake.\n";
+ protocolEx._message = "encountered a violation of the ssl protocol during handshake\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
@@ -333,7 +333,7 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout)
ProtocolException protocolEx(__FILE__, __LINE__);
// Protocol Error: Unexpected EOF.
- protocolEx._message = "Encountered an EOF that violates the SSL Protocol.\n";
+ protocolEx._message = "encountered an EOF that violates the ssl protocol\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
@@ -344,7 +344,7 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout)
{
ProtocolException protocolEx(__FILE__, __LINE__);
- protocolEx._message = "Encountered a violation of the SSL Protocol.\n";
+ protocolEx._message = "encountered a violation of the ssl protocol\n";
protocolEx._message += sslGetErrors();
throw protocolEx;
diff --git a/cpp/src/Ice/SslTransceiver.cpp b/cpp/src/Ice/SslTransceiver.cpp
index f2c95c9757a..f8a17d761ee 100644
--- a/cpp/src/Ice/SslTransceiver.cpp
+++ b/cpp/src/Ice/SslTransceiver.cpp
@@ -74,7 +74,7 @@ IceInternal::SslTransceiver::read(Buffer& buf, int timeout)
{
if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)
{
- _logger->trace(_traceLevels->securityCat, "WRN Connection::read() returning no bytes read.");
+ _logger->trace(_traceLevels->securityCat, "WRN reading from ssl connection returns no bytes");
}
}
}
diff --git a/cpp/src/Ice/SystemOpenSSL.cpp b/cpp/src/Ice/SystemOpenSSL.cpp
index 6250b087593..f24c2567a92 100644
--- a/cpp/src/Ice/SystemOpenSSL.cpp
+++ b/cpp/src/Ice/SystemOpenSSL.cpp
@@ -57,7 +57,7 @@ IceSSL::OpenSSL::System::createConnection(ContextType connectionType, int socket
{
UnsupportedContextException unsupportedException(__FILE__, __LINE__);
- unsupportedException._message = "Unable to create ClientServer connections.";
+ unsupportedException._message = "unable to create client/server connections";
throw unsupportedException;
}
@@ -173,26 +173,25 @@ IceSSL::OpenSSL::System::loadConfig(ContextType contextType,
{
case Client :
{
- contextString = "Client";
+ contextString = "client";
break;
}
case Server :
{
- contextString = "Server";
+ contextString = "server";
break;
}
case ClientServer :
{
- contextString = "Client/Server";
+ contextString = "client/server";
break;
}
}
- configEx._message = "No SSL configuration file specified for ";
+ configEx._message = "no ssl configuration file specified for ";
configEx._message += contextString;
- configEx._message += ".";
throw configEx;
}
@@ -240,8 +239,8 @@ IceSSL::OpenSSL::System::loadConfig(ContextType contextType,
{
ostringstream s;
- s << "Temp Certificates - Server" << endl;
- s << "--------------------------" << endl;
+ s << "temporary certificates (server)" << endl;
+ s << "-------------------------------" << endl;
s << serverTempCerts << endl;
_logger->trace(_traceLevels->securityCat, s.str());
@@ -578,7 +577,7 @@ IceSSL::OpenSSL::System::initRandSystem(const string& randBytesFiles)
// RANDFILE environment variable, or specify additional random data files in the
// SSL configuration file.
_logger->trace(_traceLevels->securityCat,
- "WRN There is a lack of random data, consider specifying additional random data files.");
+ "WRN there is a lack of random data, consider specifying additional random data files");
}
_randSeeded = (randBytesLoaded > 0 ? 1 : 0);
diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp
index 434c01c4012..52284e3cb99 100644
--- a/cpp/src/Ice/TcpAcceptor.cpp
+++ b/cpp/src/Ice/TcpAcceptor.cpp
@@ -41,18 +41,6 @@ IceInternal::TcpAcceptor::close()
}
void
-IceInternal::TcpAcceptor::shutdown()
-{
- if (_traceLevels->network >= 2)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "shutting down accepting tcp connections at " << toString();
- }
-
- ::shutdown(_fd, SHUT_RD); // Shutdown socket for reading
-}
-
-void
IceInternal::TcpAcceptor::listen()
{
try
diff --git a/cpp/src/Ice/TcpAcceptor.h b/cpp/src/Ice/TcpAcceptor.h
index 82757cce8e4..a07b1bac279 100644
--- a/cpp/src/Ice/TcpAcceptor.h
+++ b/cpp/src/Ice/TcpAcceptor.h
@@ -32,7 +32,6 @@ public:
virtual SOCKET fd();
virtual void close();
- virtual void shutdown();
virtual void listen();
virtual TransceiverPtr accept(int);
virtual std::string toString() const;
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index 5c8caa70197..82ceade9ff7 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -288,7 +288,8 @@ IceInternal::ThreadPool::run()
}
EventHandlerPtr handler;
-
+ std::pair<SOCKET, bool> remove(INVALID_SOCKET, false);
+
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
@@ -321,152 +322,165 @@ IceInternal::ThreadPool::run()
//
// Handlers are permanently removed.
//
- for (vector<pair<SOCKET, bool> >::iterator p = _removes.begin(); p != _removes.end(); ++p)
+ remove = _removes.front();
+ _removes.pop_front();
+ map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(remove.first);
+ assert(p != _handlerMap.end());
+ FD_CLR(p->first, &_fdSet);
+ handler = p->second;
+ }
+
+ if (!handler)
+ {
+//
+// Optimization for WIN32 specific version of fd_set. Looping with a
+// FD_ISSET test like for Unix is very unefficient for WIN32.
+//
+#ifdef WIN32
+ //
+ // Round robin for the filedescriptors.
+ //
+ if (fdSet.fd_count == 0)
{
- map<SOCKET, EventHandlerPtr>::iterator q = _handlerMap.find(p->first);
- assert(q != _handlerMap.end());
- FD_CLR(p->first, &_fdSet);
- if (p->second) // Call finished() on the handler?
- {
- q->second->finished();
- }
- if (q->second->server())
+ Error out(_logger);
+ out << "select() in thread pool returned " << ret << " but no filedescriptor is readable";
+ goto repeatSelect;
+ }
+
+ SOCKET largerFd = _maxFd + 1;
+ SOCKET smallestFd = _maxFd + 1;
+ for (u_short i = 0; i < fdSet.fd_count; ++i)
+ {
+ SOCKET fd = fdSet.fd_array[i];
+ assert(fd != INVALID_SOCKET);
+
+ if (fd > _lastFd || _lastFd == INVALID_SOCKET)
{
- --_servers;
+ largerFd = min(largerFd, fd);
}
- _handlerMap.erase(q);
+
+ smallestFd = min(smallestFd, fd);
}
- _removes.clear();
- _maxFd = _fdIntrRead;
- _minFd = _fdIntrRead;
- if (!_handlerMap.empty())
+
+ if (largerFd <= _maxFd)
{
- _maxFd = max(_maxFd, (--_handlerMap.end())->first);
- _minFd = min(_minFd, _handlerMap.begin()->first);
+ assert(largerFd >= _minFd);
+ _lastFd = largerFd;
}
- if (_handlerMap.empty() || _servers == 0)
+ else
{
- notifyAll(); // For waitUntil...Finished() methods.
+ assert(smallestFd >= _minFd && smallestFd <= _maxFd);
+ _lastFd = smallestFd;
}
-
+#else
//
- // Selected filedescriptors may have changed, I
- // therefore need to repeat the select().
+ // Round robin for the filedescriptors.
//
- shutdown = clearInterrupt();
- goto repeatSelect;
- }
-
-//
-// Optimization for WIN32 specific version of fd_set. Looping with a
-// FD_ISSET test like for Unix is very unefficient for WIN32.
-//
-#ifdef WIN32
- //
- // Round robin for the filedescriptors.
- //
- if (fdSet.fd_count == 0)
- {
- Error out(_logger);
- out << "select() in thread pool returned " << ret << " but no filedescriptor is readable";
- goto repeatSelect;
- }
-
- SOCKET largerFd = _maxFd + 1;
- SOCKET smallestFd = _maxFd + 1;
- for (u_short i = 0; i < fdSet.fd_count; ++i)
- {
- SOCKET fd = fdSet.fd_array[i];
- assert(fd != INVALID_SOCKET);
-
- if (fd > _lastFd || _lastFd == INVALID_SOCKET)
+ if (_lastFd < _minFd - 1 || _lastFd == INVALID_SOCKET)
{
- largerFd = min(largerFd, fd);
+ _lastFd = _minFd - 1;
}
-
- smallestFd = min(smallestFd, fd);
+
+ int loops = 0;
+ do
+ {
+ if (++_lastFd > _maxFd)
+ {
+ ++loops;
+ _lastFd = _minFd;
+ }
+ }
+ while (!FD_ISSET(_lastFd, &fdSet) && loops <= 1);
+
+ if (loops > 1)
+ {
+ Error out(_logger);
+ out << "select() in thread pool returned " << ret << " but no filedescriptor is readable";
+ goto repeatSelect;
+ }
+#endif
+
+ if (_lastFd == _fdIntrRead)
+ {
+ shutdown = clearInterrupt();
+ goto repeatSelect;
+ }
+
+ map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(_lastFd);
+ if(p == _handlerMap.end())
+ {
+ Error out(_logger);
+ out << "filedescriptor " << _lastFd << " not registered with the thread pool";
+ goto repeatSelect;
+ }
+
+ handler = p->second;
}
+ }
+
+ assert(handler);
- if (largerFd <= _maxFd)
- {
- assert(largerFd >= _minFd);
- _lastFd = largerFd;
- }
- else
- {
- assert(smallestFd >= _minFd && smallestFd <= _maxFd);
- _lastFd = smallestFd;
- }
-#else
+ if (remove.first != INVALID_SOCKET)
+ {
//
- // Round robin for the filedescriptors.
+ // Call finished() on a handler if necessary.
//
- if (_lastFd < _minFd - 1 || _lastFd == INVALID_SOCKET)
+ if (remove.second)
{
- _lastFd = _minFd - 1;
+ handler->finished();
}
-
- int loops = 0;
- do
+
{
- if (++_lastFd > _maxFd)
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(remove.first);
+ assert(p != _handlerMap.end());
+ _handlerMap.erase(p);
+ _maxFd = _fdIntrRead;
+ _minFd = _fdIntrRead;
+ if (!_handlerMap.empty())
{
- ++loops;
- _lastFd = _minFd;
+ _maxFd = max(_maxFd, (--_handlerMap.end())->first);
+ _minFd = min(_minFd, _handlerMap.begin()->first);
+ }
+ if (handler->server())
+ {
+ --_servers;
+ }
+ if (_handlerMap.empty() || _servers == 0)
+ {
+ notifyAll(); // For waitUntil...Finished() methods.
}
}
- while (!FD_ISSET(_lastFd, &fdSet) && loops <= 1);
-
- if (loops > 1)
- {
- Error out(_logger);
- out << "select() in thread pool returned " << ret << " but no filedescriptor is readable";
- goto repeatSelect;
- }
-#endif
-
- if (_lastFd == _fdIntrRead)
- {
- shutdown = clearInterrupt();
- goto repeatSelect;
- }
-
- map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(_lastFd);
- if(p == _handlerMap.end())
- {
- Error out(_logger);
- out << "filedescriptor " << _lastFd << " not registered with the thread pool";
- goto repeatSelect;
- }
-
- handler = p->second;
}
-
- //
- // If the handler is "readable", try to read a message.
- //
- BasicStream stream(_instance);
- if (handler->readable())
+ else
{
- try
- {
- read(handler);
- }
- catch (const TimeoutException&) // Expected.
- {
- goto repeatSelect;
- }
- catch (const LocalException& ex)
+ //
+ // If the handler is "readable", try to read a message.
+ //
+ BasicStream stream(_instance);
+ if (handler->readable())
{
- handler->exception(ex);
- goto repeatSelect;
+ try
+ {
+ read(handler);
+ }
+ catch (const TimeoutException&) // Expected.
+ {
+ goto repeatSelect;
+ }
+ catch (const LocalException& ex)
+ {
+ handler->exception(ex);
+ goto repeatSelect;
+ }
+
+ stream.swap(handler->_stream);
+ assert(stream.i == stream.b.end());
}
- stream.swap(handler->_stream);
- assert(stream.i == stream.b.end());
+ handler->message(stream);
}
-
- handler->message(stream);
}
}
diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h
index 973df01bff2..dd19af17cf1 100644
--- a/cpp/src/Ice/ThreadPool.h
+++ b/cpp/src/Ice/ThreadPool.h
@@ -21,7 +21,7 @@
#include <Ice/LoggerF.h>
#include <Ice/PropertiesF.h>
#include <Ice/EventHandlerF.h>
-#include <list>
+#include <deque>
#ifndef WIN32
# define SOCKET int
@@ -70,7 +70,7 @@ private:
SOCKET _fdIntrWrite;
fd_set _fdSet;
std::vector<std::pair<SOCKET, EventHandlerPtr> > _adds;
- std::vector<std::pair<SOCKET, bool> > _removes;
+ std::deque<std::pair<SOCKET, bool> > _removes;
std::map<SOCKET, EventHandlerPtr> _handlerMap;
int _servers;
int _timeout;