Skip to content

Commit

Permalink
[XrdCl] On read-timeout, if the stream is broken, make sure the reque…
Browse files Browse the repository at this point in the history
…st and its handler are not double deleted.
  • Loading branch information
simonmichal committed Feb 6, 2017
1 parent 14930a0 commit dd4784b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/XrdCl/XrdClAsyncSocketHandler.cc
Expand Up @@ -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;
}
}

//----------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion src/XrdCl/XrdClStream.cc
Expand Up @@ -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
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -953,6 +955,7 @@ namespace XrdCl
*pChannelData );
if( !st.IsOK() )
{
isBroken = true;
scopedLock.UnLock();
OnError( substream, st );
}
Expand Down
2 changes: 1 addition & 1 deletion src/XrdCl/XrdClStream.hh
Expand Up @@ -226,7 +226,7 @@ namespace XrdCl
//------------------------------------------------------------------------
//! On read timeout
//------------------------------------------------------------------------
void OnReadTimeout( uint16_t subStream );
void OnReadTimeout( uint16_t subStream, bool &isBroken );

//------------------------------------------------------------------------
//! On write timeout
Expand Down

0 comments on commit dd4784b

Please sign in to comment.