From ae42952eb87b175159fe442369b34fa96d432be5 Mon Sep 17 00:00:00 2001 From: Michal Simon Date: Wed, 25 Jan 2017 15:03:21 +0100 Subject: [PATCH 1/3] [XrdCl] On read-timeout, if the stream is broken, make sure the request and its handler are not double deleted. --- src/XrdCl/XrdClAsyncSocketHandler.cc | 14 +++++++++++++- src/XrdCl/XrdClStream.cc | 5 ++++- src/XrdCl/XrdClStream.hh | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/XrdCl/XrdClAsyncSocketHandler.cc b/src/XrdCl/XrdClAsyncSocketHandler.cc index 5732b16a20a..aa182dac4a3 100644 --- a/src/XrdCl/XrdClAsyncSocketHandler.cc +++ b/src/XrdCl/XrdClAsyncSocketHandler.cc @@ -821,7 +821,19 @@ namespace XrdCl //---------------------------------------------------------------------------- void AsyncSocketHandler::OnReadTimeout() { - pStream->OnReadTimeout( pSubStreamNum ); + bool isBroken = false; + pStream->OnReadTimeout( pSubStreamNum, isBroken ); + + if( isBroken ) + { + // if we are here it means Stream::OnError has been + // called from inside of Stream::OnReadTimeout, this + // in turn means that the ownership of following + // pointers, has been transfered to the inQueue + pIncoming = 0; + pOutgoing = 0; + pOutHandler = 0; + } } //---------------------------------------------------------------------------- diff --git a/src/XrdCl/XrdClStream.cc b/src/XrdCl/XrdClStream.cc index 3c57799faa4..023a0f3a635 100644 --- a/src/XrdCl/XrdClStream.cc +++ b/src/XrdCl/XrdClStream.cc @@ -903,8 +903,10 @@ namespace XrdCl //---------------------------------------------------------------------------- // Call back when a message has been reconstructed //---------------------------------------------------------------------------- - void Stream::OnReadTimeout( uint16_t substream ) + void Stream::OnReadTimeout( uint16_t substream, bool &isBroken ) { + isBroken = false; + //-------------------------------------------------------------------------- // We only take the main stream into account //-------------------------------------------------------------------------- @@ -953,6 +955,7 @@ namespace XrdCl *pChannelData ); if( !st.IsOK() ) { + isBroken = true; scopedLock.UnLock(); OnError( substream, st ); } diff --git a/src/XrdCl/XrdClStream.hh b/src/XrdCl/XrdClStream.hh index b5fbb60b228..7ee83d73b64 100644 --- a/src/XrdCl/XrdClStream.hh +++ b/src/XrdCl/XrdClStream.hh @@ -226,7 +226,7 @@ namespace XrdCl //------------------------------------------------------------------------ //! On read timeout //------------------------------------------------------------------------ - void OnReadTimeout( uint16_t subStream ); + void OnReadTimeout( uint16_t subStream, bool &isBroken ); //------------------------------------------------------------------------ //! On write timeout From b6ac123a37c91a5d25e1abef5d22a893916539dd Mon Sep 17 00:00:00 2001 From: Mattias Ellert Date: Mon, 6 Feb 2017 15:00:28 +0100 Subject: [PATCH 2/3] Use bitwise not --- src/XrdClient/XrdClient.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/XrdClient/XrdClient.cc b/src/XrdClient/XrdClient.cc index dc1ee845b79..a641cceff2c 100644 --- a/src/XrdClient/XrdClient.cc +++ b/src/XrdClient/XrdClient.cc @@ -1372,7 +1372,7 @@ bool XrdClient::OpenFileWhenRedirected(char *newfhandle, bool &wasopen) Info(XrdClientDebug::kHIDEBUG, "OpenFileWhenRedirected", "Stripping off the 'delete' option." ); - options &= !kXR_delete; + options &= ~kXR_delete; options |= kXR_open_updt; } @@ -1380,7 +1380,7 @@ bool XrdClient::OpenFileWhenRedirected(char *newfhandle, bool &wasopen) Info(XrdClientDebug::kHIDEBUG, "OpenFileWhenRedirected", "Stripping off the 'new' option." ); - options &= !kXR_new; + options &= ~kXR_new; options |= kXR_open_updt; } From 376999fe1473ddefcec22610a3e5e61e4f82a672 Mon Sep 17 00:00:00 2001 From: Mattias Ellert Date: Mon, 6 Feb 2017 15:01:03 +0100 Subject: [PATCH 3/3] Proper fallthrough --- src/XrdSecpwd/XrdSecProtocolpwd.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/XrdSecpwd/XrdSecProtocolpwd.cc b/src/XrdSecpwd/XrdSecProtocolpwd.cc index 3bb437beb43..d9616faa76e 100644 --- a/src/XrdSecpwd/XrdSecProtocolpwd.cc +++ b/src/XrdSecpwd/XrdSecProtocolpwd.cc @@ -1015,7 +1015,7 @@ if (hs->Step == kXPS_init) SessionSt.options = kOptsClntTty; } // case kXPS_puk: -if (hs->Step == kXPS_puk) +if ((hs->Step == kXPS_init) || (hs->Step == kXPS_puk)) { // After auto-reg request, server puk have been saved in ParseClientInput: // we need to start a full normal login now @@ -1045,8 +1045,6 @@ if (hs->Step == kXPS_puk) } } // case kXPS_signedrtag: // (after kXRC_verifysrv) -if (hs->Step == kXPS_signedrtag) - { // // Add the username if (hs->User.length()) { @@ -1081,7 +1079,6 @@ if (hs->Step == kXPS_signedrtag) SessionSt.options |= kOptsChngPwd; // nextstep = kXPC_normal; - } break; case kXPS_credsreq: