diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/SslAcceptor.cpp | 15 | ||||
-rw-r--r-- | cpp/src/Ice/SslConnector.cpp | 15 | ||||
-rw-r--r-- | cpp/src/Ice/SslTransceiver.cpp | 248 | ||||
-rw-r--r-- | cpp/src/Ice/SslTransceiver.h | 11 |
4 files changed, 3 insertions, 286 deletions
diff --git a/cpp/src/Ice/SslAcceptor.cpp b/cpp/src/Ice/SslAcceptor.cpp index e704e86334b..1eaa4c01776 100644 --- a/cpp/src/Ice/SslAcceptor.cpp +++ b/cpp/src/Ice/SslAcceptor.cpp @@ -11,12 +11,9 @@ #pragma warning(disable:4786)
#endif
-#ifdef SSL_EXTENSION
#include <Ice/SslFactory.h>
#include <Ice/SslSystem.h>
#include <Ice/Properties.h>
-#endif
-
#include <Ice/SslAcceptor.h> #include <Ice/SslTransceiver.h> #include <Ice/Instance.h> @@ -24,11 +21,7 @@ #include <Ice/Logger.h> #include <Ice/Network.h> #include <Ice/Exception.h> -
-#ifdef SSL_EXTENSION
#include <Ice/SslException.h>
-#endif
-
#include <sstream>
using namespace std; @@ -37,13 +30,10 @@ using namespace IceInternal; using std::string;
using std::ostringstream;
-
-#ifdef SSL_EXTENSION
using IceSecurity::Ssl::Connection;
using IceSecurity::Ssl::Factory;
using IceSecurity::Ssl::System;
using IceSecurity::Ssl::ShutdownException;
-#endif
int IceInternal::SslAcceptor::fd() @@ -112,7 +102,6 @@ IceInternal::SslAcceptor::accept(int timeout) _logger->trace(_traceLevels->networkCat, s.str()); } -#ifdef SSL_EXTENSION
// This is the Ice SSL Configuration File on which we will base
// all connections in this communicator.
string configFile = _instance->properties()->getProperty("Ice.Ssl.Config");
@@ -156,10 +145,6 @@ IceInternal::SslAcceptor::accept(int timeout) Factory::releaseSystem(sslSystem);
sslSystem = 0;
-#else
- TransceiverPtr transPtr = new SslTransceiver(_instance, fd);
-#endif
-
return transPtr;
} diff --git a/cpp/src/Ice/SslConnector.cpp b/cpp/src/Ice/SslConnector.cpp index dc819faa798..c1b8b33d409 100644 --- a/cpp/src/Ice/SslConnector.cpp +++ b/cpp/src/Ice/SslConnector.cpp @@ -11,11 +11,8 @@ #pragma warning(disable:4786)
#endif
-#ifdef SSL_EXTENSION
#include <Ice/SslFactory.h>
#include <Ice/SslSystem.h>
-#endif
-
#include <Ice/SslConnector.h> #include <Ice/SslTransceiver.h> #include <Ice/Instance.h> @@ -24,11 +21,7 @@ #include <Ice/Network.h> #include <Ice/Properties.h>
#include <Ice/Exception.h> -
-#ifdef SSL_EXTENSION
#include <Ice/SslException.h>
-#endif
-
#include <sstream>
using namespace std; @@ -37,13 +30,10 @@ using namespace IceInternal; using std::ostringstream;
using std::string;
-
-#ifdef SSL_EXTENSION
using IceSecurity::Ssl::Connection;
using IceSecurity::Ssl::Factory;
using IceSecurity::Ssl::System;
using IceSecurity::Ssl::ShutdownException; -#endif
TransceiverPtr IceInternal::SslConnector::connect(int timeout) @@ -65,7 +55,6 @@ IceInternal::SslConnector::connect(int timeout) _logger->trace(_traceLevels->networkCat, s.str()); } -#ifdef SSL_EXTENSION
// This is the Ice SSL Configuration File on which we will base
// all connections in this communicator.
string configFile = _instance->properties()->getProperty("Ice.Ssl.Config");
@@ -109,10 +98,6 @@ IceInternal::SslConnector::connect(int timeout) Factory::releaseSystem(sslSystem);
sslSystem = 0;
-#else
- TransceiverPtr transPtr = new SslTransceiver(_instance, fd);
-#endif
-
return transPtr;
} diff --git a/cpp/src/Ice/SslTransceiver.cpp b/cpp/src/Ice/SslTransceiver.cpp index 76af7b5daf7..2a153b3d375 100644 --- a/cpp/src/Ice/SslTransceiver.cpp +++ b/cpp/src/Ice/SslTransceiver.cpp @@ -8,10 +8,8 @@ // // ********************************************************************** -#ifdef SSL_EXTENSION
+#include <Ice/Security.h>
#include <Ice/SslConnection.h>
-#endif -
#include <Ice/SslTransceiver.h>
#include <Ice/Instance.h> #include <Ice/TraceLevels.h> @@ -19,23 +17,16 @@ #include <Ice/Buffer.h> #include <Ice/Network.h> #include <Ice/Exception.h> -
-#ifdef SSL_EXTENSION
-#include <Ice/Security.h>
#include <Ice/SslException.h>
#include <sstream>
-#endif
using namespace std; using namespace Ice; using namespace IceInternal; - -#ifdef SSL_EXTENSION
using IceSecurity::SecurityException;
using IceSecurity::Ssl::InitException;
using IceSecurity::Ssl::ReInitException;
using IceSecurity::Ssl::ShutdownException;
-#endif
int IceInternal::SslTransceiver::fd() @@ -46,9 +37,7 @@ IceInternal::SslTransceiver::fd() void IceInternal::SslTransceiver::close() { -#ifndef SSL_EXTENSION
METHOD_INV("SslTransceiver::close()");
-#endif
if (_traceLevels->network >= 1) { @@ -63,17 +52,13 @@ IceInternal::SslTransceiver::close() ::shutdown(fd, SHUT_RDWR); // helps to unblock threads in recv() closeSocket(fd); -#ifndef SSL_EXTENSION
METHOD_RET("SslTransceiver::close()");
-#endif
} void IceInternal::SslTransceiver::shutdown() { -#ifndef SSL_EXTENSION
METHOD_INV("SslTransceiver::shutdown()");
-#endif
if (_traceLevels->network >= 2) { @@ -84,235 +69,22 @@ IceInternal::SslTransceiver::shutdown() ::shutdown(_fd, SHUT_WR); // Shutdown socket for writing -#ifndef SSL_EXTENSION
METHOD_RET("SslTransceiver::shutdown()");
-#endif
} void IceInternal::SslTransceiver::write(Buffer& buf, int timeout) {
-#ifndef SSL_EXTENSION
METHOD_INV("SslTransceiver::write()")
- int packetSize = buf.b.end() - buf.i; - -#ifdef WIN32 - // - // Limit packet size to avoid performance problems on WIN32 - // - if (packetSize > 64 * 1024) - { - packetSize = 64 * 1024; - } -#endif - - while (buf.i != buf.b.end()) - { - int ret = ::send(_fd, buf.i, packetSize, 0); - - if (ret == 0) - { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; - throw ex; - } - - if (ret == SOCKET_ERROR) - { - if (interrupted()) - { - continue; - } - - if (noBuffers() && packetSize > 1024) - { - packetSize /= 2; - continue; - } - - if (wouldBlock()) - { - int fd = _fd; // Copy fd, in case another thread calls close() - if (fd != -1) - { - repeatSelect: - int ret; - FD_SET(fd, &_wFdSet); - if (timeout >= 0) - { - struct timeval tv; - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000; - ret = ::select(fd + 1, 0, &_wFdSet, 0, &tv); - } - else - { - ret = ::select(fd + 1, 0, &_wFdSet, 0, 0); - } - - if (ret == SOCKET_ERROR) - { - if (interrupted()) - { - goto repeatSelect; - } - - SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; - } - - if (ret == 0) - { - throw TimeoutException(__FILE__, __LINE__); - } - } - - continue; - } - - if (connectionLost()) - { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; - } - else - { - SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; - } - } - - if (_traceLevels->network >= 3) - { - ostringstream s; - s << "sent " << ret << " of " << packetSize << " bytes via ssl\n" << toString(); - _logger->trace(_traceLevels->networkCat, s.str()); - } - - buf.i += ret; - - if (packetSize > buf.b.end() - buf.i) - { - packetSize = buf.b.end() - buf.i; - } - }
-
- METHOD_INV("SslTransceiver::write()");
-#else
-
_sslConnection->write(buf, timeout);
-
-#endif
+ METHOD_RET("SslTransceiver::write()");
} void IceInternal::SslTransceiver::read(Buffer& buf, int timeout) { -#ifndef SSL_EXTENSION
METHOD_INV("SslTransceiver::read()");
- int packetSize = buf.b.end() - buf.i; - - while (buf.i != buf.b.end()) - { - int ret = ::recv(_fd, buf.i, packetSize, 0); - - if (ret == 0) - { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; - throw ex; - } - - if (ret == SOCKET_ERROR) - { - if (interrupted()) - { - continue; - } - - if (noBuffers() && packetSize > 1024) - { - packetSize /= 2; - continue; - } - - if (wouldBlock()) - { - int fd = _fd; // Copy fd, in case another thread calls close() - if (fd != -1) - { - repeatSelect: - int ret; - FD_SET(fd, &_rFdSet); - if (timeout >= 0) - { - struct timeval tv; - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000; - ret = ::select(fd + 1, &_rFdSet, 0, 0, &tv); - } - else - { - ret = ::select(fd + 1, &_rFdSet, 0, 0, 0); - } - - if (ret == SOCKET_ERROR) - { - if (interrupted()) - { - goto repeatSelect; - } - - SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; - } - - if (ret == 0) - { - throw TimeoutException(__FILE__, __LINE__); - } - } - - continue; - } - - if (connectionLost()) - { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; - } - else - { - SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; - } - } - - if (_traceLevels->network >= 3) - { - ostringstream s; - s << "received " << ret << " of " << packetSize << " bytes via ssl\n" << toString(); - _logger->trace(_traceLevels->networkCat, s.str()); - } - - buf.i += ret; - - if (packetSize > buf.b.end() - buf.i) - { - packetSize = buf.b.end() - buf.i; - } - } -
- METHOD_INV("SslTransceiver::read()");
-#else
-
if (!_sslConnection->read(buf, timeout))
{
ConnectionLostException clEx(__FILE__, __LINE__);
@@ -320,7 +92,7 @@ IceInternal::SslTransceiver::read(Buffer& buf, int timeout) throw clEx;
}
-#endif
+ METHOD_RET("SslTransceiver::read()");
} string @@ -329,24 +101,14 @@ IceInternal::SslTransceiver::toString() const return fdToString(_fd); } -#ifndef SSL_EXTENSION
-IceInternal::SslTransceiver::SslTransceiver(const InstancePtr& instance, int fd) :
- _instance(instance),
- _fd(fd),
- _traceLevels(instance->traceLevels()),
- _logger(instance->logger())
-#else
IceInternal::SslTransceiver::SslTransceiver(const InstancePtr& instance, int fd, Connection* sslConnection) :
_instance(instance),
_fd(fd),
_traceLevels(instance->traceLevels()),
_logger(instance->logger()),
_sslConnection(sslConnection)
-#endif { -#ifdef SSL_EXTENSION
assert(sslConnection != 0);
-#endif
FD_ZERO(&_rFdSet); FD_ZERO(&_wFdSet); @@ -356,20 +118,16 @@ IceInternal::SslTransceiver::~SslTransceiver() { assert(_fd == INVALID_SOCKET); -#ifdef SSL_EXTENSION
cleanUpSSL();
-#endif
} void
IceInternal::SslTransceiver::cleanUpSSL()
{
-#ifdef SSL_EXTENSION
if (_sslConnection != 0)
{
_sslConnection->shutdown();
delete _sslConnection;
_sslConnection = 0;
}
-#endif
}
diff --git a/cpp/src/Ice/SslTransceiver.h b/cpp/src/Ice/SslTransceiver.h index ad2fce1e167..13c3ab8998f 100644 --- a/cpp/src/Ice/SslTransceiver.h +++ b/cpp/src/Ice/SslTransceiver.h @@ -11,10 +11,7 @@ #ifndef ICE_SSL_TRANSCEIVER_H #define ICE_SSL_TRANSCEIVER_H -#ifdef SSL_EXTENSION
#include <Ice/SslConnection.h>
-#endif
-
#include <Ice/InstanceF.h> #include <Ice/TraceLevelsF.h> #include <Ice/LoggerF.h> @@ -23,9 +20,7 @@ namespace IceInternal { -#ifdef SSL_EXTENSION
using IceSecurity::Ssl::Connection;
-#endif
class SslConnector; class SslAcceptor; @@ -43,11 +38,7 @@ public: private: -#ifdef SSL_EXTENSION
SslTransceiver(const InstancePtr&, int, Connection*);
-#else
- SslTransceiver(const InstancePtr&, int);
-#endif
virtual ~SslTransceiver();
void cleanUpSSL();
@@ -61,9 +52,7 @@ private: fd_set _rFdSet; fd_set _wFdSet; -#ifdef SSL_EXTENSION
Connection* _sslConnection;
-#endif
}; } |