![]() |
XRootD
|
#include <XrdClAsyncSocketHandler.hh>
Public Member Functions | |
AsyncSocketHandler (const URL &url, Poller *poller, TransportHandler *transport, AnyObject *channelData, uint16_t subStreamNum, Stream *strm) | |
Constructor. More... | |
~AsyncSocketHandler () | |
Destructor. More... | |
XRootDStatus | Close () |
Close the connection. More... | |
XRootDStatus | Connect (time_t timeout) |
Connect to the currently set address. More... | |
XRootDStatus | DisableUplink () |
Disable uplink. More... | |
XRootDStatus | EnableUplink () |
Enable uplink. More... | |
virtual void | Event (uint8_t type, XrdCl::Socket *) |
Handle a socket event. More... | |
const XrdNetAddr & | GetAddress () const |
Get the address that the socket is connected to. More... | |
std::string | GetHostName () |
Get hostname. More... | |
std::string | GetIpAddr () |
Get IP address. More... | |
std::string | GetIpStack () const |
Get the IP stack. More... | |
time_t | GetLastActivity () |
Get timestamp of last registered socket activity. More... | |
const std::string & | GetStreamName () |
Get stream name. More... | |
void | SetAddress (const XrdNetAddr &address) |
Set address. More... | |
![]() | |
virtual | ~SocketHandler () |
virtual void | Finalize () |
Finalizer. More... | |
virtual void | Initialize (Poller *) |
Initializer. More... | |
Protected Member Functions | |
bool | CheckHSWait () XRD_WARN_UNUSED_RESULT |
XRootDStatus | DoTlsHandShake () |
bool | EventRead (uint8_t type) XRD_WARN_UNUSED_RESULT |
bool | EventWrite (uint8_t type) XRD_WARN_UNUSED_RESULT |
bool | HandleHandShake (std::unique_ptr< Message > msg) XRD_WARN_UNUSED_RESULT |
kXR_int32 | HandleWaitRsp (Message *rsp) |
bool | HandShakeNextStep (bool done) XRD_WARN_UNUSED_RESULT |
virtual bool | OnConnectionReturn () XRD_WARN_UNUSED_RESULT |
void | OnFault (XRootDStatus st) |
void | OnFaultWhileHandshaking (XRootDStatus st) |
void | OnHeaderCorruption () |
bool | OnRead () XRD_WARN_UNUSED_RESULT |
bool | OnReadTimeout () XRD_WARN_UNUSED_RESULT |
bool | OnReadWhileHandshaking () XRD_WARN_UNUSED_RESULT |
bool | OnTimeoutWhileHandshaking () XRD_WARN_UNUSED_RESULT |
bool | OnTLSHandShake () XRD_WARN_UNUSED_RESULT |
bool | OnWrite () XRD_WARN_UNUSED_RESULT |
bool | OnWriteTimeout () XRD_WARN_UNUSED_RESULT |
bool | OnWriteWhileHandshaking () XRD_WARN_UNUSED_RESULT |
bool | SendHSMsg () XRD_WARN_UNUSED_RESULT |
Static Protected Member Functions | |
static std::string | ToStreamName (const URL &url, uint16_t strmnb) |
Convert Stream object and sub-stream number to stream name. More... | |
Protected Attributes | |
std::unique_ptr< AsyncHSReader > | hsreader |
std::unique_ptr< AsyncHSWriter > | hswriter |
AnyObject * | pChannelData |
time_t | pConnectionStarted |
time_t | pConnectionTimeout |
std::unique_ptr< HandShakeData > | pHandShakeData |
bool | pHandShakeDone |
time_t | pHSWaitSeconds |
time_t | pHSWaitStarted |
time_t | pLastActivity |
Poller * | pPoller |
XrdNetAddr | pSockAddr |
Socket * | pSocket |
Stream * | pStream |
std::string | pStreamName |
uint16_t | pSubStreamNum |
uint16_t | pTimeoutResolution |
bool | pTlsHandShakeOngoing |
TransportHandler * | pTransport |
URL | pUrl |
std::unique_ptr< AsyncMsgWriter > | reqwriter |
std::unique_ptr< AsyncMsgReader > | rspreader |
Additional Inherited Members | |
![]() | |
enum | EventType { ReadyToRead = 0x01 , ReadTimeOut = 0x02 , ReadyToWrite = 0x04 , WriteTimeOut = 0x08 } |
Event type. More... | |
![]() | |
static std::string | EventTypeToString (uint8_t event) |
Translate the event type to a string. More... | |
Utility class handling asynchronous socket interactions and forwarding events to the parent stream.
Definition at line 43 of file XrdClAsyncSocketHandler.hh.
XrdCl::AsyncSocketHandler::AsyncSocketHandler | ( | const URL & | url, |
Poller * | poller, | ||
TransportHandler * | transport, | ||
AnyObject * | channelData, | ||
uint16_t | subStreamNum, | ||
Stream * | strm | ||
) |
Constructor.
Definition at line 35 of file XrdClAsyncSocketHandler.cc.
References XrdCl::DefaultTimeoutResolution, XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), pChannelData, pLastActivity, pSocket, pTimeoutResolution, and XrdCl::Socket::SetChannelID().
XrdCl::AsyncSocketHandler::~AsyncSocketHandler | ( | ) |
Destructor.
Definition at line 69 of file XrdClAsyncSocketHandler.cc.
References Close(), and pSocket.
|
protected |
Definition at line 862 of file XrdClAsyncSocketHandler.cc.
References XrdCl::AsyncSockMsg, XrdCl::Log::Debug(), XrdCl::DefaultEnv::GetLog(), pHSWaitSeconds, pHSWaitStarted, pStreamName, and SendHSMsg().
Referenced by EventRead().
XRootDStatus XrdCl::AsyncSocketHandler::Close | ( | ) |
Close the connection.
Definition at line 186 of file XrdClAsyncSocketHandler.cc.
References XrdCl::AsyncSockMsg, XrdCl::Socket::Close(), XrdCl::Log::Debug(), XrdCl::TransportHandler::Disconnect(), XrdCl::DefaultEnv::GetLog(), pChannelData, pPoller, pSocket, pStreamName, pSubStreamNum, pTransport, and XrdCl::Poller::RemoveSocket().
Referenced by ~AsyncSocketHandler().
XRootDStatus XrdCl::AsyncSocketHandler::Connect | ( | time_t | timeout | ) |
Connect to the currently set address.
Definition at line 78 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Poller::AddSocket(), XrdCl::AsyncSockMsg, XrdCl::Socket::Close(), XrdCl::Socket::Connecting, XrdCl::Socket::ConnectToAddress(), XrdCl::Log::Debug(), XrdCl::DefaultTCPKeepAlive, XrdCl::DefaultTCPKeepAliveInterval, XrdCl::DefaultTCPKeepAliveProbes, XrdCl::DefaultTCPKeepAliveTime, XrdCl::Poller::EnableWriteNotification(), XrdCl::Log::Error(), XrdCl::errPollerError, XrdNetAddrInfo::Family(), XrdNetAddrInfo::fmtAdv6, XrdNetAddrInfo::Format(), XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), XrdCl::DefaultEnv::GetLog(), XrdCl::Socket::Initialize(), XrdCl::Status::IsOK(), pConnectionStarted, pConnectionTimeout, pHandShakeDone, pHSWaitSeconds, pHSWaitStarted, pLastActivity, pPoller, pSockAddr, pSocket, pStreamName, pTimeoutResolution, pTlsHandShakeOngoing, XrdCl::Poller::RemoveSocket(), XrdCl::Socket::SetSockOpt(), XrdCl::Socket::SetStatus(), XrdCl::Status::status, XrdCl::stFatal, and XrdCl::Status::ToString().
|
inline |
Disable uplink.
Definition at line 105 of file XrdClAsyncSocketHandler.hh.
References XrdCl::Poller::EnableWriteNotification(), XrdCl::errPollerError, pPoller, pSocket, and XrdCl::stFatal.
Referenced by XrdCl::Tls::Connect(), OnWriteWhileHandshaking(), XrdCl::Tls::Read(), and XrdCl::Tls::Send().
|
protected |
Definition at line 772 of file XrdClAsyncSocketHandler.cc.
References XrdCl::AsyncSockMsg, XrdCl::Status::code, XrdCl::Log::Debug(), XrdCl::URL::GetHostName(), XrdCl::DefaultEnv::GetLog(), XrdCl::Log::Info(), OnFaultWhileHandshaking(), pSocket, pStreamName, pTlsHandShakeOngoing, pUrl, XrdCl::suRetry, and XrdCl::Socket::TlsHandShake().
Referenced by HandleHandShake(), and OnTLSHandShake().
|
inline |
Enable uplink.
Definition at line 95 of file XrdClAsyncSocketHandler.hh.
References XrdCl::Poller::EnableWriteNotification(), XrdCl::errPollerError, pPoller, pSocket, pTimeoutResolution, and XrdCl::stFatal.
Referenced by XrdCl::Tls::Connect(), HandShakeNextStep(), XrdCl::Tls::Read(), XrdCl::Tls::Send(), and SendHSMsg().
|
virtual |
Handle a socket event.
Implements XrdCl::SocketHandler.
Definition at line 210 of file XrdClAsyncSocketHandler.cc.
References EventRead(), EventWrite(), XrdCl::Socket::MapEvent(), and pSocket.
|
inlineprotected |
Definition at line 234 of file XrdClAsyncSocketHandler.cc.
References CheckHSWait(), likely, OnRead(), OnReadTimeout(), OnReadWhileHandshaking(), OnTimeoutWhileHandshaking(), OnTLSHandShake(), pHandShakeDone, pHSWaitSeconds, pLastActivity, pTlsHandShakeOngoing, XrdCl::SocketHandler::ReadTimeOut, XrdCl::SocketHandler::ReadyToRead, and unlikely.
Referenced by Event().
|
inlineprotected |
Definition at line 274 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Socket::Connecting, XrdCl::Socket::GetStatus(), likely, OnConnectionReturn(), OnTimeoutWhileHandshaking(), OnTLSHandShake(), OnWrite(), OnWriteTimeout(), OnWriteWhileHandshaking(), pHandShakeDone, pHSWaitSeconds, pLastActivity, pSocket, pTlsHandShakeOngoing, XrdCl::SocketHandler::ReadyToWrite, unlikely, and XrdCl::SocketHandler::WriteTimeOut.
Referenced by Event().
|
inline |
Get the address that the socket is connected to.
Definition at line 72 of file XrdClAsyncSocketHandler.hh.
References pSockAddr.
std::string XrdCl::AsyncSocketHandler::GetHostName | ( | ) |
Get hostname.
Definition at line 904 of file XrdClAsyncSocketHandler.cc.
References XrdNetAddrInfo::Name(), and pSockAddr.
std::string XrdCl::AsyncSocketHandler::GetIpAddr | ( | ) |
Get IP address.
Definition at line 894 of file XrdClAsyncSocketHandler.cc.
References XrdNetAddrInfo::fmtAddr, XrdNetAddrInfo::Format(), XrdNetAddrInfo::noPort, and pSockAddr.
std::string XrdCl::AsyncSocketHandler::GetIpStack | ( | ) | const |
Get the IP stack.
Definition at line 884 of file XrdClAsyncSocketHandler.cc.
References XrdNetAddrInfo::isIPType(), XrdNetAddrInfo::isMapped(), and pSockAddr.
|
inline |
Get timestamp of last registered socket activity.
Definition at line 123 of file XrdClAsyncSocketHandler.hh.
References pLastActivity.
|
inline |
|
protected |
Definition at line 577 of file XrdClAsyncSocketHandler.cc.
References XrdCl::AsyncSockMsg, XrdCl::Status::code, XrdCl::Log::Debug(), DoTlsHandShake(), XrdCl::Log::Error(), XrdCl::errSocketTimeout, XrdCl::DefaultEnv::GetLog(), HandleWaitRsp(), XrdCl::TransportHandler::HandShake(), HandShakeNextStep(), XrdCl::Socket::IsEncrypted(), XrdCl::Status::IsOK(), XrdCl::TransportHandler::NeedEncryption(), OnFaultWhileHandshaking(), pChannelData, pConnectionStarted, pConnectionTimeout, pHandShakeData, pHSWaitSeconds, pHSWaitStarted, pSocket, pStreamName, pTransport, SendHSMsg(), XrdCl::stError, XrdCl::suDone, and XrdCl::suRetry.
Referenced by OnReadWhileHandshaking().
Definition at line 848 of file XrdClAsyncSocketHandler.cc.
References ServerResponse::body, XrdCl::Buffer::GetBuffer(), ServerResponse::hdr, kXR_wait, and ServerResponseHeader::status.
Referenced by HandleHandShake().
|
protected |
Definition at line 664 of file XrdClAsyncSocketHandler.cc.
References EnableUplink(), hsreader, hswriter, XrdCl::Stream::OnConnect(), OnFaultWhileHandshaking(), pChannelData, pHandShakeData, pHandShakeDone, pSocket, pStream, pStreamName, pSubStreamNum, pTransport, reqwriter, rspreader, and SendHSMsg().
Referenced by HandleHandShake(), and OnTLSHandShake().
|
protectedvirtual |
Definition at line 317 of file XrdClAsyncSocketHandler.cc.
References XrdCl::AsyncSockMsg, XrdCl::Status::code, XrdCl::Socket::Connected, XrdCl::Socket::Cork(), XrdCl::Log::Debug(), XrdCl::Poller::EnableReadNotification(), XrdCl::errConnectionError, XrdCl::Log::Error(), XrdCl::errPollerError, XrdCl::errSocketOptError, XrdCl::DefaultEnv::GetLog(), XrdCl::Socket::GetServerAddress(), XrdCl::Socket::GetSockName(), XrdCl::Socket::GetSockOpt(), XrdCl::Stream::GetURL(), XrdCl::TransportHandler::HandShake(), hsreader, hswriter, XrdCl::Status::IsOK(), XrdCl::Stream::OnConnectError(), pChannelData, pHandShakeData, pPoller, pSocket, pStream, pStreamName, pSubStreamNum, pTimeoutResolution, pTransport, XrdCl::Socket::SetStatus(), XrdCl::stError, XrdCl::stFatal, XrdCl::suRetry, and XrdSysE2T().
Referenced by EventWrite().
|
protected |
Definition at line 706 of file XrdClAsyncSocketHandler.cc.
References XrdCl::AsyncSockMsg, XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), XrdCl::Stream::OnError(), pStream, pStreamName, pSubStreamNum, and XrdCl::Status::ToString().
Referenced by OnRead(), OnReadWhileHandshaking(), and OnWrite().
|
protected |
Definition at line 718 of file XrdClAsyncSocketHandler.cc.
References XrdCl::AsyncSockMsg, XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), XrdCl::Stream::OnConnectError(), pStream, pStreamName, pSubStreamNum, and XrdCl::Status::ToString().
Referenced by DoTlsHandShake(), HandleHandShake(), HandShakeNextStep(), OnReadWhileHandshaking(), OnTimeoutWhileHandshaking(), OnWriteWhileHandshaking(), and SendHSMsg().
|
protected |
Definition at line 760 of file XrdClAsyncSocketHandler.cc.
References XrdCl::errSocketError, XrdCl::Stream::ForceError(), pStream, and XrdCl::stError.
Referenced by OnRead().
|
protected |
Definition at line 497 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Status::code, XrdCl::errCorruptedHeader, XrdCl::errInternal, XrdCl::Status::IsOK(), OnFault(), OnHeaderCorruption(), rspreader, XrdCl::stError, and XrdCl::suRetry.
Referenced by EventRead().
|
protected |
Definition at line 738 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Stream::OnReadTimeout(), pStream, and pSubStreamNum.
Referenced by EventRead().
|
protected |
Definition at line 546 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Status::code, XrdCl::errInternal, HandleHandShake(), hsreader, XrdCl::Status::IsOK(), OnFault(), OnFaultWhileHandshaking(), XrdCl::stError, and XrdCl::suDone.
Referenced by EventRead().
|
protected |
Definition at line 746 of file XrdClAsyncSocketHandler.cc.
References XrdCl::errSocketTimeout, OnFaultWhileHandshaking(), pConnectionStarted, pConnectionTimeout, and XrdCl::stError.
Referenced by EventRead(), and EventWrite().
|
inlineprotected |
Definition at line 800 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Status::code, DoTlsHandShake(), XrdCl::TransportHandler::HandShakeDone(), HandShakeNextStep(), XrdCl::Status::IsOK(), pChannelData, pHandShakeData, pTransport, and XrdCl::suRetry.
Referenced by EventRead(), and EventWrite().
|
protected |
Definition at line 419 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Status::code, XrdCl::Stream::DisableIfEmpty(), XrdCl::errInternal, XrdCl::Status::IsOK(), OnFault(), pStream, pSubStreamNum, reqwriter, XrdCl::stError, and XrdCl::suRetry.
Referenced by EventWrite().
|
protected |
Definition at line 730 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Stream::OnWriteTimeout(), pStream, and pSubStreamNum.
Referenced by EventWrite().
|
protected |
Definition at line 453 of file XrdClAsyncSocketHandler.cc.
References XrdCl::Status::code, DisableUplink(), hswriter, XrdCl::Status::IsOK(), OnFaultWhileHandshaking(), and XrdCl::suRetry.
Referenced by EventWrite().
|
protected |
Definition at line 815 of file XrdClAsyncSocketHandler.cc.
References EnableUplink(), XrdCl::errInternal, hswriter, OnFaultWhileHandshaking(), pHandShakeData, pHSWaitSeconds, and XrdCl::stError.
Referenced by CheckHSWait(), HandleHandShake(), and HandShakeNextStep().
|
inline |
|
staticprotected |
Convert Stream object and sub-stream number to stream name.
Definition at line 199 of file XrdClAsyncSocketHandler.cc.
References XrdCl::URL::GetHostId().
|
protected |
Definition at line 289 of file XrdClAsyncSocketHandler.hh.
Referenced by HandShakeNextStep(), OnConnectionReturn(), and OnReadWhileHandshaking().
|
protected |
Definition at line 287 of file XrdClAsyncSocketHandler.hh.
Referenced by HandShakeNextStep(), OnConnectionReturn(), OnWriteWhileHandshaking(), and SendHSMsg().
|
protected |
Definition at line 270 of file XrdClAsyncSocketHandler.hh.
Referenced by AsyncSocketHandler(), Close(), HandleHandShake(), HandShakeNextStep(), OnConnectionReturn(), and OnTLSHandShake().
|
protected |
Definition at line 279 of file XrdClAsyncSocketHandler.hh.
Referenced by Connect(), HandleHandShake(), and OnTimeoutWhileHandshaking().
|
protected |
Definition at line 280 of file XrdClAsyncSocketHandler.hh.
Referenced by Connect(), HandleHandShake(), and OnTimeoutWhileHandshaking().
|
protected |
Definition at line 276 of file XrdClAsyncSocketHandler.hh.
Referenced by HandleHandShake(), HandShakeNextStep(), OnConnectionReturn(), OnTLSHandShake(), and SendHSMsg().
|
protected |
Definition at line 277 of file XrdClAsyncSocketHandler.hh.
Referenced by Connect(), EventRead(), EventWrite(), and HandShakeNextStep().
|
protected |
Definition at line 283 of file XrdClAsyncSocketHandler.hh.
Referenced by CheckHSWait(), Connect(), EventRead(), EventWrite(), HandleHandShake(), and SendHSMsg().
|
protected |
Definition at line 282 of file XrdClAsyncSocketHandler.hh.
Referenced by CheckHSWait(), Connect(), and HandleHandShake().
|
protected |
Definition at line 281 of file XrdClAsyncSocketHandler.hh.
Referenced by AsyncSocketHandler(), Connect(), EventRead(), EventWrite(), and GetLastActivity().
|
protected |
Definition at line 268 of file XrdClAsyncSocketHandler.hh.
Referenced by Close(), Connect(), DisableUplink(), EnableUplink(), and OnConnectionReturn().
|
protected |
Definition at line 275 of file XrdClAsyncSocketHandler.hh.
Referenced by Connect(), GetAddress(), GetHostName(), GetIpAddr(), GetIpStack(), and SetAddress().
|
protected |
Definition at line 274 of file XrdClAsyncSocketHandler.hh.
Referenced by AsyncSocketHandler(), ~AsyncSocketHandler(), Close(), Connect(), DisableUplink(), DoTlsHandShake(), EnableUplink(), Event(), EventWrite(), HandleHandShake(), HandShakeNextStep(), and OnConnectionReturn().
|
protected |
Definition at line 272 of file XrdClAsyncSocketHandler.hh.
Referenced by HandShakeNextStep(), OnConnectionReturn(), OnFault(), OnFaultWhileHandshaking(), OnHeaderCorruption(), OnReadTimeout(), OnWrite(), and OnWriteTimeout().
|
protected |
Definition at line 273 of file XrdClAsyncSocketHandler.hh.
Referenced by CheckHSWait(), Close(), Connect(), DoTlsHandShake(), GetStreamName(), HandleHandShake(), HandShakeNextStep(), OnConnectionReturn(), OnFault(), and OnFaultWhileHandshaking().
|
protected |
Definition at line 271 of file XrdClAsyncSocketHandler.hh.
Referenced by Close(), HandShakeNextStep(), OnConnectionReturn(), OnFault(), OnFaultWhileHandshaking(), OnReadTimeout(), OnWrite(), and OnWriteTimeout().
|
protected |
Definition at line 278 of file XrdClAsyncSocketHandler.hh.
Referenced by AsyncSocketHandler(), Connect(), EnableUplink(), and OnConnectionReturn().
|
protected |
Definition at line 285 of file XrdClAsyncSocketHandler.hh.
Referenced by Connect(), DoTlsHandShake(), EventRead(), and EventWrite().
|
protected |
Definition at line 269 of file XrdClAsyncSocketHandler.hh.
Referenced by Close(), HandleHandShake(), HandShakeNextStep(), OnConnectionReturn(), and OnTLSHandShake().
|
protected |
Definition at line 284 of file XrdClAsyncSocketHandler.hh.
Referenced by DoTlsHandShake().
|
protected |
Definition at line 290 of file XrdClAsyncSocketHandler.hh.
Referenced by HandShakeNextStep(), and OnWrite().
|
protected |
Definition at line 288 of file XrdClAsyncSocketHandler.hh.
Referenced by HandShakeNextStep(), and OnRead().