summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/SslConnectionOpenSSLClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/SslConnectionOpenSSLClient.cpp')
-rw-r--r--cpp/src/Ice/SslConnectionOpenSSLClient.cpp65
1 files changed, 39 insertions, 26 deletions
diff --git a/cpp/src/Ice/SslConnectionOpenSSLClient.cpp b/cpp/src/Ice/SslConnectionOpenSSLClient.cpp
index 209f9725c7a..d1d39597c0c 100644
--- a/cpp/src/Ice/SslConnectionOpenSSLClient.cpp
+++ b/cpp/src/Ice/SslConnectionOpenSSLClient.cpp
@@ -77,35 +77,50 @@ IceSecurity::Ssl::OpenSSL::ClientConnection::init(int timeout)
{
JTCSyncT<JTCMutex> sync(_initMutex);
- int retCode = 0;
-
- ICE_METHOD_INV("OpenSSL::ClientConnection::init()");
+ ICE_METHOD_INV("OpenSSL::ClientConnection::init()");
+
+ if (_timeoutEncountered)
+ {
+ throw TimeoutException(__FILE__, __LINE__);
+ }
+
+ int retCode = SSL_is_init_finished(_sslConnection);
- if (!SSL_is_init_finished(_sslConnection))
+ while (!retCode)
{
- int i = 0;
-
- if (initWantRead)
- {
- i = readSelect(timeout);
- }
- else if (initWantWrite)
- {
- i = writeSelect(timeout);
+ int i = 0;
+
+ _readTimeout = timeout;
+
+ try
+ {
+ if (_initWantRead)
+ {
+ i = readSelect(timeout);
+ }
+ else if (_initWantWrite)
+ {
+ i = writeSelect(timeout);
+ }
+ }
+ catch (const TimeoutException&)
+ {
+ _timeoutEncountered = true;
+ throw;
}
- if (initWantRead && i == 0)
+ if (_initWantRead && i == 0)
{
return 0;
}
- if (initWantWrite && i == 0)
+ if (_initWantWrite && i == 0)
{
return 0;
}
- initWantRead = 0;
- initWantWrite = 0;
+ _initWantRead = 0;
+ _initWantWrite = 0;
int result = connect();
@@ -118,13 +133,13 @@ IceSecurity::Ssl::OpenSSL::ClientConnection::init(int timeout)
{
case SSL_ERROR_WANT_READ:
{
- initWantRead = 1;
+ _initWantRead = 1;
break;
}
case SSL_ERROR_WANT_WRITE:
{
- initWantWrite = 1;
+ _initWantWrite = 1;
break;
}
@@ -201,14 +216,12 @@ IceSecurity::Ssl::OpenSSL::ClientConnection::init(int timeout)
if (retCode > 0)
{
+ _readTimeout = timeout > _handshakeReadTimeout ? timeout : _handshakeReadTimeout;
+
// Init finished, look at the connection information.
showConnectionInfo();
}
}
- else
- {
- retCode = 1;
- }
ICE_METHOD_RET("OpenSSL::ClientConnection::init()");
@@ -255,8 +268,8 @@ IceSecurity::Ssl::OpenSSL::ClientConnection::write(Buffer& buf, int timeout)
int totalBytesWritten = 0;
int bytesWritten = 0;
- int packetSize = buf.b.end() - buf.i;
-
+ int packetSize = buf.b.end() - buf.i;
+
#ifdef WIN32
//
// Limit packet size to avoid performance problems on WIN32.
@@ -447,7 +460,7 @@ IceSecurity::Ssl::OpenSSL::ClientConnection::showConnectionInfo()
ICE_METHOD_INV("OpenSSL::ClientConnection::showConnectionInfo()");
// Only in extreme cases do we enable this, partially because it doesn't use the Logger.
- if (ICE_SECURITY_LEVEL_PROTOCOL_DEBUG)
+ if (ICE_SECURITY_LEVEL_PROTOCOL_DEBUG && 0)
{
ICE_PROTOCOL_DEBUG("Begin Connection Information");