Skip to content

Commit

Permalink
[XrdCl] AsynSocketHandler: enhance OnWrite logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed May 3, 2021
1 parent 1578f62 commit 1e0f760
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/XrdCl/XrdClAsyncSocketHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ namespace XrdCl
//--------------------------------------------------------------------------
Message *msg = toWrite;
size_t leftToBeWritten = msg->GetSize()-msg->GetCursor();
if( !leftToBeWritten ) return XRootDStatus();

while( leftToBeWritten )
{
Expand Down Expand Up @@ -525,6 +526,7 @@ namespace XrdCl
XRootDStatus AsyncSocketHandler::WriteMessageAndRaw( Message *toWrite, Message *&sign )
{
XRootDStatus st;
Log *log = DefaultEnv::GetLog();

if( sign )
{
Expand All @@ -542,6 +544,8 @@ namespace XrdCl
uint32_t bytesWritten = 0;
st = pOutHandler->WriteMessageBody( pSocket, bytesWritten );
pOutMsgSize += bytesWritten;
log->Dump( AsyncSockMsg, "[%s] Wrote %d bytes of message (0x%x) body.",
pStreamName.c_str(), bytesWritten, toWrite );
if( !st.IsOK() || st.code == suRetry )
return st;
}
Expand Down
3 changes: 2 additions & 1 deletion src/XrdCl/XrdClSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ namespace XrdCl
//! @param kbuff : data to be written
//! @return : the amount of data actually written
//------------------------------------------------------------------------
XRootDStatus Socket::Send( XrdSys::KernelBuffer &kbuff )
XRootDStatus Socket::Send( XrdSys::KernelBuffer &kbuff, int &bytesWritten )
{
if( pTls ) return XRootDStatus( stError, errNotSupported, 0,
"Cannot send a kernel-buffer over TLS." );
Expand All @@ -493,6 +493,7 @@ namespace XrdCl

if( status <= 0 )
return ClassifyErrno( errno );
bytesWritten += status;
return XRootDStatus();
}

Expand Down
2 changes: 1 addition & 1 deletion src/XrdCl/XrdClSocket.hh
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace XrdCl
//! @param kbuff : data to be written
//! @return : the amount of data actually written
//------------------------------------------------------------------------
XRootDStatus Send( XrdSys::KernelBuffer &kbuff );
XRootDStatus Send( XrdSys::KernelBuffer &kbuff, int &bytesWritten );

//----------------------------------------------------------------------------
//! Read helper for raw socket
Expand Down
13 changes: 8 additions & 5 deletions src/XrdCl/XrdClXRootDMsgHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1469,11 +1469,12 @@ namespace XrdCl

while( leftToBeWritten )
{
int bytesWritten = 0;
Status st = socket->Send( buffer + pAsyncOffset, leftToBeWritten, bytesWritten );
int btswrt = 0;
Status st = socket->Send( buffer + pAsyncOffset, leftToBeWritten, btswrt );
if( !st.IsOK() || st.code == suRetry ) return st;
pAsyncOffset += bytesWritten;
leftToBeWritten -= bytesWritten;
pAsyncOffset += btswrt;
leftToBeWritten -= btswrt;
bytesWritten += btswrt;
}
//----------------------------------------------------------------------
// Remember that we have moved to the next chunk, also clear the offset
Expand Down Expand Up @@ -1508,7 +1509,9 @@ namespace XrdCl
//------------------------------------------------------------------------
while( !pKBuff->Empty() )
{
Status st = socket->Send( *pKBuff );
int btswrt = 0;
Status st = socket->Send( *pKBuff, btswrt );
bytesWritten += btswrt;
if( !st.IsOK() || st.code == suRetry ) return st;
}

Expand Down

0 comments on commit 1e0f760

Please sign in to comment.