From 7e38183932e8601551c2c1629a714ad9449b6796 Mon Sep 17 00:00:00 2001 From: Michal Simon Date: Wed, 21 Aug 2019 17:36:45 +0200 Subject: [PATCH] [XrdCl/XrdTls] Retry if SSL_read/write yield SSL_ERROR_NONE. --- src/XrdCl/XrdClTls.cc | 15 +++++++++++++++ src/XrdTls/XrdTlsSocket.cc | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/XrdCl/XrdClTls.cc b/src/XrdCl/XrdClTls.cc index c3f4ed9a5da..b19c56fe457 100644 --- a/src/XrdCl/XrdClTls.cc +++ b/src/XrdCl/XrdClTls.cc @@ -129,6 +129,12 @@ namespace XrdCl } pTlsHSRevert = None; + //------------------------------------------------------------------------ + // If we didn't manage to read any data wait for another read event + //------------------------------------------------------------------------ + if( bytesRead == 0 ) + return Status( stOK, suRetry ); + return status; } @@ -185,6 +191,15 @@ namespace XrdCl } pTlsHSRevert = None; + //------------------------------------------------------------------------ + // If we didn't manage to read any data wait for another write event + // + // Adding this by symmetry, never actually experienced this (for reads + // it has been experienced) + //------------------------------------------------------------------------ + if( bytesWritten == 0 ) + return Status( stOK, suRetry ); + return status; } diff --git a/src/XrdTls/XrdTlsSocket.cc b/src/XrdTls/XrdTlsSocket.cc index bb473f55eb5..15df7a45911 100644 --- a/src/XrdTls/XrdTlsSocket.cc +++ b/src/XrdTls/XrdTlsSocket.cc @@ -467,6 +467,7 @@ XrdTls::RC XrdTlsSocket::Read( char *buffer, size_t size, int &bytesRead ) // not the handshake actually is finished (semi-accurate) // error = Diagnose(SSL_get_error( pImpl->ssl, rc )); + if( error == XrdTls::RC::TLS_AOK ) bytesRead = 0; pImpl->hsDone = bool( SSL_is_init_finished( pImpl->ssl ) ); // The connection creator may wish that we wait for the handshake to @@ -565,6 +566,7 @@ XrdTls::RC XrdTlsSocket::Write( const char *buffer, size_t size, // not the handshake actually is finished (semi-accurate) // pImpl->hsDone = bool( SSL_is_init_finished( pImpl->ssl ) ); + if( error == XrdTls::RC::TLS_AOK ) bytesWritten = 0; error = Diagnose(SSL_get_error( pImpl->ssl, rc )); // The connection creator may wish that we wait for the handshake to