XRootD
Loading...
Searching...
No Matches
XrdCl::AsyncHSWriter Class Reference

Utility class encapsulating writing hand-shake request logic. More...

#include <XrdClAsyncHSWriter.hh>

+ Collaboration diagram for XrdCl::AsyncHSWriter:

Public Member Functions

 AsyncHSWriter (Socket &socket, const std::string &strmname)
 
bool HasMsg ()
 Check if writer was assigned with a message.
 
void Replay ()
 Replay the message that has been sent.
 
void Reset (Message *msg=nullptr)
 Reset the state of the object (makes it ready to read out next msg)
 
XRootDStatus Write ()
 Write the request into the socket.
 

Detailed Description

Utility class encapsulating writing hand-shake request logic.

Definition at line 38 of file XrdClAsyncHSWriter.hh.

Constructor & Destructor Documentation

◆ AsyncHSWriter()

XrdCl::AsyncHSWriter::AsyncHSWriter ( Socket socket,
const std::string &  strmname 
)
inline

Constructor

Parameters
socket: the socket with the message to be read out
strmname: stream name

Definition at line 47 of file XrdClAsyncHSWriter.hh.

48 : writestage( WriteRequest ),
49 socket( socket ),
50 strmname( strmname ),
51 outmsg( nullptr )
52 {
53 }

Member Function Documentation

◆ HasMsg()

bool XrdCl::AsyncHSWriter::HasMsg ( )
inline

Check if writer was assigned with a message.

Definition at line 77 of file XrdClAsyncHSWriter.hh.

78 {
79 return bool( outmsg );
80 }

◆ Replay()

void XrdCl::AsyncHSWriter::Replay ( )
inline

Replay the message that has been sent.

Definition at line 67 of file XrdClAsyncHSWriter.hh.

68 {
69 if( !outmsg ) return;
70 writestage = WriteRequest;
71 outmsg->SetCursor( 0 );
72 }

◆ Reset()

void XrdCl::AsyncHSWriter::Reset ( Message msg = nullptr)
inline

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

Definition at line 58 of file XrdClAsyncHSWriter.hh.

59 {
60 writestage = WriteRequest;
61 outmsg.reset( msg );
62 }

◆ Write()

XRootDStatus XrdCl::AsyncHSWriter::Write ( )
inline

Write the request into the socket.

Definition at line 85 of file XrdClAsyncHSWriter.hh.

86 {
87 Log *log = DefaultEnv::GetLog();
88 while( true )
89 {
90 switch( writestage )
91 {
92 case WriteRequest:
93 {
94 XRootDStatus st = socket.Send( *outmsg, strmname );
95 if( !st.IsOK() || st.code == suRetry ) return st;
96 //----------------------------------------------------------------
97 // The next step is to write the signature
98 //----------------------------------------------------------------
99 writestage = WriteDone;
100 continue;
101 }
102
103 case WriteDone:
104 {
105 XRootDStatus st = socket.Flash();
106 if( !st.IsOK() )
107 {
108 log->Error( AsyncSockMsg, "[%s] Unable to flash the socket: %s",
109 strmname.c_str(), XrdSysE2T( st.errNo ) );
110 }
111 return st;
112 }
113 }
114 // just in case ...
115 break;
116 }
117 //----------------------------------------------------------------------
118 // We are done
119 //----------------------------------------------------------------------
120 return XRootDStatus();
121 }
const char * XrdSysE2T(int errcode)
Definition XrdSysE2T.cc:99
static Log * GetLog()
Get default log.
virtual XRootDStatus Send(const char *buffer, size_t size, int &bytesWritten)
XRootDStatus Flash()
const uint16_t suRetry
const uint64_t AsyncSockMsg
XrdSysError Log
Definition XrdConfig.cc:112

References XrdCl::AsyncSockMsg, XrdCl::Status::code, XrdCl::Status::errNo, XrdCl::Log::Error(), XrdCl::Socket::Flash(), XrdCl::DefaultEnv::GetLog(), XrdCl::Status::IsOK(), XrdCl::Socket::Send(), XrdCl::suRetry, and XrdSysE2T().

+ Here is the call graph for this function:

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