Skip to content

Commit

Permalink
[XrdCl] Fix memory leak (hostList) on statuful msg t/o.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal authored and gganis committed Nov 23, 2021
1 parent e1a6e15 commit 61259cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/XrdCl/XrdClMessageUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ namespace XrdCl
msgHandler->SetLoadBalancer( sendParams.loadBalancer );

HostList *list = 0;
list = new HostList();
if( sendParams.hostList )
{
list = sendParams.hostList;
sendParams.hostList = nullptr;
}
else
list = new HostList();
list->push_back( url );
msgHandler->SetHostList( list );

Expand Down
6 changes: 3 additions & 3 deletions src/XrdCl/XrdClXRootDMsgHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1683,9 +1683,9 @@ namespace XrdCl
pSidMgr->ReleaseSID( req->header.streamid );
}

HostList *hosts = pHosts;
HostList *hosts = pHosts.release();
if( !finalrsp )
pHosts = new HostList( *hosts );
pHosts.reset( new HostList( *hosts ) );

pResponseHandler->HandleResponseWithHosts( status, response, hosts );

Expand Down Expand Up @@ -2965,7 +2965,7 @@ namespace XrdCl

pResponseHandler->HandleResponseWithHosts( new XRootDStatus(),
resp,
pHosts );
pHosts.release() );
delete this;

return;
Expand Down
7 changes: 2 additions & 5 deletions src/XrdCl/XrdClXRootDMsgHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ namespace XrdCl
pExpiration( 0 ),
pRedirectAsAnswer( false ),
pOksofarAsAnswer( false ),
pHosts( 0 ),
pHasLoadBalancer( false ),
pHasSessionId( false ),
pChunkList( 0 ),
Expand Down Expand Up @@ -230,7 +229,6 @@ namespace XrdCl
pResponseHandler = reinterpret_cast<ResponseHandler*>( 0xDEADBEEF );
pPostMaster = reinterpret_cast<PostMaster*>( 0xDEADBEEF );
pLFileHandler = reinterpret_cast<LocalFileHandler*>( 0xDEADBEEF );
pHosts = reinterpret_cast<HostList*>( 0xDEADBEEF );
pChunkList = reinterpret_cast<ChunkList*>( 0xDEADBEEF );
pEffectiveDataServerUrl = reinterpret_cast<URL*>( 0xDEADBEEF );

Expand Down Expand Up @@ -380,8 +378,7 @@ namespace XrdCl
//------------------------------------------------------------------------
void SetHostList( HostList *hostList )
{
delete pHosts;
pHosts = hostList;
pHosts.reset( hostList );
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -689,7 +686,7 @@ namespace XrdCl
time_t pExpiration;
bool pRedirectAsAnswer;
bool pOksofarAsAnswer;
HostList *pHosts;
std::unique_ptr<HostList> pHosts;
bool pHasLoadBalancer;
HostInfo pLoadBalancer;
bool pHasSessionId;
Expand Down

0 comments on commit 61259cd

Please sign in to comment.