From e81bb2ccbed96ae88c26550375131b0659ae587b Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Fri, 30 Dec 2016 14:56:35 +0100 Subject: Fixed ICE-7476 - Ice/background test failure on stretch with SSL --- cpp/src/IceSSL/OpenSSLTransceiverI.cpp | 146 ++++++++++++++------------------- 1 file changed, 62 insertions(+), 84 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp index 863b758791d..a1e61c81535 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp @@ -204,44 +204,37 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B } case SSL_ERROR_SYSCALL: { - if(ret == 0) + if(IceInternal::interrupted()) { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; - throw ex; + break; } - if(ret == -1) + if(IceInternal::wouldBlock()) { - if(IceInternal::interrupted()) + if(SSL_want_read(_ssl)) { - break; + return IceInternal::SocketOperationRead; } - - if(IceInternal::wouldBlock()) + else if(SSL_want_write(_ssl)) { - if(SSL_want_read(_ssl)) - { - return IceInternal::SocketOperationRead; - } - else if(SSL_want_write(_ssl)) - { - return IceInternal::SocketOperationWrite; - } - - break; + return IceInternal::SocketOperationWrite; } - if(IceInternal::connectionLost()) - { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSocketErrno(); - throw ex; - } + break; + } + + if(IceInternal::connectionLost() || IceInternal::getSocketErrno() == 0) + { + ConnectionLostException ex(__FILE__, __LINE__); + ex.error = IceInternal::getSocketErrno(); + throw ex; + } + else + { + SocketException ex(__FILE__, __LINE__); + ex.error = IceInternal::getSocketErrno(); + throw ex; } - SocketException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSocketErrno(); - throw ex; } case SSL_ERROR_SSL: { @@ -389,42 +382,35 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf) } case SSL_ERROR_SYSCALL: { - if(ret == -1) + if(IceInternal::interrupted()) { - if(IceInternal::interrupted()) - { - continue; - } - - if(IceInternal::noBuffers() && packetSize > 1024) - { - packetSize /= 2; - continue; - } + continue; + } - if(IceInternal::wouldBlock()) - { - assert(SSL_want_write(_ssl)); - return IceInternal::SocketOperationWrite; - } + if(IceInternal::noBuffers() && packetSize > 1024) + { + packetSize /= 2; + continue; + } - if(IceInternal::connectionLost()) - { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSocketErrno(); - throw ex; - } + if(IceInternal::wouldBlock()) + { + assert(SSL_want_write(_ssl)); + return IceInternal::SocketOperationWrite; } - if(ret == 0) + + if(IceInternal::connectionLost() || IceInternal::getSocketErrno() == 0) { ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; + ex.error = IceInternal::getSocketErrno(); + throw ex; + } + else + { + SocketException ex(__FILE__, __LINE__); + ex.error = IceInternal::getSocketErrno(); throw ex; } - - SocketException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSocketErrno(); - throw ex; } case SSL_ERROR_SSL: { @@ -501,43 +487,35 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf) } case SSL_ERROR_SYSCALL: { - if(ret == -1) + if(IceInternal::interrupted()) { - if(IceInternal::interrupted()) - { - continue; - } - - if(IceInternal::noBuffers() && packetSize > 1024) - { - packetSize /= 2; - continue; - } + continue; + } - if(IceInternal::wouldBlock()) - { - assert(SSL_want_read(_ssl)); - return IceInternal::SocketOperationRead; - } + if(IceInternal::noBuffers() && packetSize > 1024) + { + packetSize /= 2; + continue; + } - if(IceInternal::connectionLost()) - { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSocketErrno(); - throw ex; - } + if(IceInternal::wouldBlock()) + { + assert(SSL_want_read(_ssl)); + return IceInternal::SocketOperationRead; } - if(ret == 0) + if(IceInternal::connectionLost() || IceInternal::getSocketErrno() == 0) { ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; + ex.error = IceInternal::getSocketErrno(); + throw ex; + } + else + { + SocketException ex(__FILE__, __LINE__); + ex.error = IceInternal::getSocketErrno(); throw ex; } - - SocketException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSocketErrno(); - throw ex; } case SSL_ERROR_SSL: { -- cgit v1.2.3