summaryrefslogtreecommitdiff
path: root/cpp/src/IceSSL/SslConnectionOpenSSL.cpp
diff options
context:
space:
mode:
authorAnthony Neal <aneal@zeroc.com>2002-05-01 20:45:50 +0000
committerAnthony Neal <aneal@zeroc.com>2002-05-01 20:45:50 +0000
commit3f1d399d186ea2c00e446de589c2c74aa08f5969 (patch)
tree40560525601e33410a21fd93f6fc615bb821fafb /cpp/src/IceSSL/SslConnectionOpenSSL.cpp
parentfix (diff)
downloadice-3f1d399d186ea2c00e446de589c2c74aa08f5969.tar.bz2
ice-3f1d399d186ea2c00e446de589c2c74aa08f5969.tar.xz
ice-3f1d399d186ea2c00e446de589c2c74aa08f5969.zip
Fixes to the handling of SSL_ERROR_ZERO_RETURN in the init(), as well as
the proper clearing of the error queue before SSL_* calls.
Diffstat (limited to 'cpp/src/IceSSL/SslConnectionOpenSSL.cpp')
-rw-r--r--cpp/src/IceSSL/SslConnectionOpenSSL.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/cpp/src/IceSSL/SslConnectionOpenSSL.cpp b/cpp/src/IceSSL/SslConnectionOpenSSL.cpp
index 8d916eee26e..67d213b742a 100644
--- a/cpp/src/IceSSL/SslConnectionOpenSSL.cpp
+++ b/cpp/src/IceSSL/SslConnectionOpenSSL.cpp
@@ -223,6 +223,7 @@ IceSSL::OpenSSL::Connection::connect()
{
assert(_sslConnection != 0);
+ ERR_clear_error();
int result = SSL_connect(_sslConnection);
setLastError(result);
@@ -235,6 +236,7 @@ IceSSL::OpenSSL::Connection::accept()
{
assert(_sslConnection != 0);
+ ERR_clear_error();
int result = SSL_accept(_sslConnection);
setLastError(result);
@@ -304,8 +306,10 @@ IceSSL::OpenSSL::Connection::pending()
int
IceSSL::OpenSSL::Connection::getLastError() const
{
- assert(_sslConnection != 0);
- return SSL_get_error(_sslConnection, _lastError);
+ assert(_sslConnection != 0);
+ int retCode = SSL_get_error(_sslConnection, _lastError);
+// std::cout << "SSL_get_error(): " << std::dec << retCode << std::endl;
+ return retCode;
}
int
@@ -313,6 +317,7 @@ IceSSL::OpenSSL::Connection::sslRead(char* buffer, int bufferSize)
{
assert(_sslConnection != 0);
+ ERR_clear_error();
int bytesRead = SSL_read(_sslConnection, buffer, bufferSize);
setLastError(bytesRead);
@@ -324,7 +329,8 @@ int
IceSSL::OpenSSL::Connection::sslWrite(char* buffer, int bufferSize)
{
assert(_sslConnection != 0);
-
+
+ ERR_clear_error();
int bytesWritten = SSL_write(_sslConnection, buffer, bufferSize);
setLastError(bytesWritten);
@@ -480,7 +486,8 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout)
case SSL_ERROR_WANT_READ:
{
if (!readSelect(timeout))
- {
+ {
+// std::cout << "SSL_ERROR_WANT_READ" << std::endl;
// Timeout and wait for them to arrive.
throw TimeoutException(__FILE__, __LINE__);
}
@@ -514,10 +521,12 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout)
{
ConnectionLostException ex(__FILE__, __LINE__);
ex.error = getSocketErrno();
+// std::cout << std::dec << clock() << " SSL_ERROR_SYSCALL: connectionLost() = " << std::dec << ex.error << std::endl;
throw ex;
}
else
{
+// std::cout << std::dec << clock() << " SSL_ERROR_SYSCALL" << std::endl;
SocketException ex(__FILE__, __LINE__);
ex.error = getSocketErrno();
throw ex;
@@ -525,6 +534,7 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout)
}
else // (bytesRead == 0)
{
+// std::cout << std::dec << clock() << " SSL_ERROR_SYSCALL: (bytesRead == 0)" << std::endl;
ConnectionLostException ex(__FILE__, __LINE__);
ex.error = 0;
throw ex;
@@ -547,6 +557,8 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout)
// But does not necessarily indicate that the underlying transport
// has been closed (in the case of Ice, it definitely hasn't yet).
+// std::cout << std::dec << clock() << " SSL_ERROR_ZERO_RETURN" << std::endl;
+// std::cout << "SslErrors:" << std::endl << sslGetErrors() << std::endl;
ConnectionLostException ex(__FILE__, __LINE__);
ex.error = getSocketErrno();
throw ex;