Loading...
Searching...
No Matches
XrdCl::AsyncHSReader Class Reference

Utility class encapsulating reading hand-shake response logic. More...

`#include <XrdClAsyncHSReader.hh>`

Collaboration diagram for XrdCl::AsyncHSReader:

## Public Member Functions

| AsyncHSReader (TransportHandler &xrdTransport, Socket &socket, const std::string &strmname, Stream &strm, uint16_t substrmnb)
XRootDStatus | Read ()
| Read out the response from the socket.
std::unique_ptr< Message > | ReleaseMsg ()
| Transfer the received message ownership.
void | Reset ()
| Reset the state of the object (makes it ready to read out next msg).

## Detailed Description

Utility class encapsulating reading hand-shake response logic.

Definition at line 36 of file XrdClAsyncHSReader.hh.

## Constructor & Destructor Documentation

## AsyncHSReader()

XrdCl::AsyncHSReader::AsyncHSReader | ( | TransportHandler & | xrdTransport,
|  | Socket & | socket,
|  | const std::string & | strmname,
|  | Stream & | strm,
|  | uint16_t | substrmnb )

inline

Constructor

Parameters

  xrdTransport | : the (xrootd) transport layer
  socket | : the socket with the message to be read out
  strmname | : stream name
  strm | : the stream encapsulating the connection
  substrmnb | : the substream number

Definition at line 48 of file XrdClAsyncHSReader.hh.

: readstage( ReadStart ),
xrdTransport( xrdTransport ),
socket( socket ),
strmname( strmname ),
strm( strm ),
substrmnb( substrmnb )
{
}

## Member Function Documentation

## Read()

XRootDStatus XrdCl::AsyncHSReader::Read | ( |  | ) |

inline

Read out the response from the socket.

Definition at line 64 of file XrdClAsyncHSReader.hh.

{
Log *log = DefaultEnv::GetLog();
while( true )
{
switch( readstage )
{
//------------------------------------------------------------------
// There is no incoming message currently being processed so we
// create a new one
//------------------------------------------------------------------
case ReadStart:
{
inmsg.reset( new Message() );
//----------------------------------------------------------------
// The next step is to read the header
//----------------------------------------------------------------
readstage = ReadHeader;
continue;
}
//------------------------------------------------------------------
// We need to read the header
//------------------------------------------------------------------
case ReadHeader:
{
XRootDStatus st = xrdTransport.GetHeader( *inmsg, &socket );
if( !st.IsOK() || st.code == suRetry ) return st;
log->Dump( AsyncSockMsg,
"[%s] Received message header, size: %d",
strmname.c_str(), inmsg->GetCursor() );
//----------------------------------------------------------------
// The next step is to read the message body
//----------------------------------------------------------------
readstage = ReadMsgBody;
continue;
}
//------------------------------------------------------------------
// We read the message to the buffer
//------------------------------------------------------------------
case ReadMsgBody:
{
XRootDStatus st = xrdTransport.GetBody( *inmsg, &socket );
if( !st.IsOK() || st.code == suRetry ) return st;
log->Dump( AsyncSockMsg, "[%s] Received a message of %d bytes",
strmname.c_str(), inmsg->GetSize() );
readstage = ReadDone;
return st;
}
case ReadDone: return XRootDStatus();
}
// just in case ...
break;
}
//----------------------------------------------------------------------
// We are done
//----------------------------------------------------------------------
return XRootDStatus();
}
XrdCl::DefaultEnv::GetLog
static Log * GetLog()
Get default log.
Definition XrdClDefaultEnv.cc:493
XrdCl::suRetry
const uint16_t suRetry
Definition XrdClStatus.hh:40
XrdCl::AsyncSockMsg
const uint64_t AsyncSockMsg
Definition XrdClConstants.hh:41
XrdGlobal::Log
XrdSysError Log
Definition XrdConfig.cc:113

References XrdCl::AsyncSockMsg, XrdCl::Status::code, XrdCl::Log::Dump(), XrdCl::DefaultEnv::GetLog(), XrdCl::Status::IsOK(), and XrdCl::suRetry.

Here is the call graph for this function:

## ReleaseMsg()

std::unique_ptr< Message > XrdCl::AsyncHSReader::ReleaseMsg | ( |  | ) |

inline

Transfer the received message ownership.

Definition at line 128 of file XrdClAsyncHSReader.hh.

{
readstage = ReadStart;
return std::move( inmsg );
}

## Reset()

void XrdCl::AsyncHSReader::Reset | ( |  | ) |

inline

Reset the state of the object (makes it ready to read out next msg).

Definition at line 137 of file XrdClAsyncHSReader.hh.

{
readstage = ReadStart;
inmsg.reset();
}

The documentation for this class was generated from the following file:

- XrdClAsyncHSReader.hh