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

A synchronize queue for incoming data. More...

#include <XrdClInQueue.hh>

+ Collaboration diagram for XrdCl::InQueue:

Public Member Functions

void AddMessageHandler (MsgHandler *handler, time_t expires, bool &rmMsg)
 
MsgHandlerGetHandlerForMessage (std::shared_ptr< Message > &msg, time_t &expires, uint16_t &action)
 
void ReAddMessageHandler (MsgHandler *handler, time_t expires)
 Re-insert the handler without scanning the cached messages.
 
void RemoveMessageHandler (MsgHandler *handler)
 Remove a listener.
 
void ReportStreamEvent (MsgHandler::StreamEvent event, XRootDStatus status)
 Report an event to the handlers.
 
void ReportTimeout (time_t now=0)
 Timeout handlers.
 

Detailed Description

A synchronize queue for incoming data.

Definition at line 36 of file XrdClInQueue.hh.

Member Function Documentation

◆ AddMessageHandler()

void XrdCl::InQueue::AddMessageHandler ( MsgHandler handler,
time_t  expires,
bool &  rmMsg 
)

Add a listener that should be notified about incoming messages

Parameters
handlermessage handler
expirestime when the message handler expires
rmMsgwill be set to true if a left over message matching the request has been removed from the queue

Definition at line 54 of file XrdClInQueue.cc.

55 {
56 uint16_t handlerSid = handler->GetSid();
57 XrdSysMutexHelper scopedLock( pMutex );
58
59 pHandlers[handlerSid] = HandlerAndExpire( handler, expires );
60 }

References XrdCl::MsgHandler::GetSid().

Referenced by XrdCl::Stream::OnMessageSent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHandlerForMessage()

MsgHandler * XrdCl::InQueue::GetHandlerForMessage ( std::shared_ptr< Message > &  msg,
time_t &  expires,
uint16_t &  action 
)

Get a message handler interested in receiving message whose header is stored in msg

Parameters
msgmessage header
expireshandle's expiration timestamp
actionthe action declared by the handler
Returns
handler or 0 if none is interested

Definition at line 66 of file XrdClInQueue.cc.

69 {
70 time_t exp = 0;
71 uint16_t act = 0;
72 uint16_t msgSid = 0;
73 MsgHandler* handler = 0;
74
75 if (DiscardMessage(*msg, msgSid))
76 {
77 return handler;
78 }
79
80 XrdSysMutexHelper scopedLock( pMutex );
81 HandlerMap::iterator it = pHandlers.find(msgSid);
82
83 if (it != pHandlers.end())
84 {
85 Log *log = DefaultEnv::GetLog();
86 handler = it->second.first;
87 act = handler->Examine( msg );
88 exp = it->second.second;
89 log->Debug( ExDbgMsg, "[msg: 0x%x] Assigned MsgHandler: 0x%x.",
90 msg.get(), handler );
91
92
94 {
95 pHandlers.erase( it );
96 log->Debug( ExDbgMsg, "[handler: 0x%x] Removed MsgHandler: 0x%x from the in-queue.",
97 handler, handler );
98 }
99 }
100
101 if( handler )
102 {
103 expires = exp;
104 action = act;
105 }
106
107 return handler;
108 }
static Log * GetLog()
Get default log.
const uint64_t ExDbgMsg
XrdSysError Log
Definition XrdConfig.cc:111

References XrdCl::Log::Debug(), XrdCl::MsgHandler::Examine(), XrdCl::ExDbgMsg, XrdCl::DefaultEnv::GetLog(), and XrdCl::MsgHandler::RemoveHandler.

Referenced by XrdCl::Stream::InstallIncHandler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReAddMessageHandler()

void XrdCl::InQueue::ReAddMessageHandler ( MsgHandler handler,
time_t  expires 
)

Re-insert the handler without scanning the cached messages.

Definition at line 113 of file XrdClInQueue.cc.

115 {
116 uint16_t handlerSid = handler->GetSid();
117 XrdSysMutexHelper scopedLock( pMutex );
118 pHandlers[handlerSid] = HandlerAndExpire( handler, expires );
119 }

References XrdCl::MsgHandler::GetSid().

Referenced by XrdCl::Stream::ForceError(), and XrdCl::Stream::OnError().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveMessageHandler()

void XrdCl::InQueue::RemoveMessageHandler ( MsgHandler handler)

Remove a listener.

Definition at line 124 of file XrdClInQueue.cc.

125 {
126 uint16_t handlerSid = handler->GetSid();
127 XrdSysMutexHelper scopedLock( pMutex );
128 pHandlers.erase(handlerSid);
129 Log *log = DefaultEnv::GetLog();
130 log->Debug( ExDbgMsg, "[handler: 0x%x] Removed MsgHandler: 0x%x from the in-queue.",
131 handler, handler );
132
133 }

References XrdCl::Log::Debug(), XrdCl::ExDbgMsg, XrdCl::DefaultEnv::GetLog(), and XrdCl::MsgHandler::GetSid().

Referenced by XrdCl::Stream::InspectStatusRsp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReportStreamEvent()

void XrdCl::InQueue::ReportStreamEvent ( MsgHandler::StreamEvent  event,
XRootDStatus  status 
)

Report an event to the handlers.

Definition at line 138 of file XrdClInQueue.cc.

140 {
141 uint8_t action = 0;
142 XrdSysMutexHelper scopedLock( pMutex );
143 for( HandlerMap::iterator it = pHandlers.begin(); it != pHandlers.end(); )
144 {
145 action = it->second.first->OnStreamEvent( event, status );
146
147 if( action & MsgHandler::RemoveHandler )
148 {
149 auto next = it; ++next;
150 pHandlers.erase( it );
151 it = next;
152 }
153 else
154 ++it;
155 }
156 }

References XrdCl::MsgHandler::RemoveHandler.

Referenced by XrdCl::Stream::ForceError(), and XrdCl::Stream::OnError().

+ Here is the caller graph for this function:

◆ ReportTimeout()

void XrdCl::InQueue::ReportTimeout ( time_t  now = 0)

Timeout handlers.

Definition at line 161 of file XrdClInQueue.cc.

162 {
163 if( !now )
164 now = ::time(0);
165
166 XrdSysMutexHelper scopedLock( pMutex );
167 HandlerMap::iterator it = pHandlers.begin();
168 while( it != pHandlers.end() )
169 {
170 if( it->second.second <= now )
171 {
172 uint8_t act = it->second.first->OnStreamEvent( MsgHandler::Timeout,
173 Status( stError, errOperationExpired ) );
174 auto next = it; ++next;
175 if( act & MsgHandler::RemoveHandler )
176 pHandlers.erase( it );
177 it = next;
178 }
179 else
180 ++it;
181 }
182 }
@ Timeout
The declared timeout has occurred.
const uint16_t errOperationExpired
const uint16_t stError
An error occurred that could potentially be retried.

References XrdCl::errOperationExpired, XrdCl::MsgHandler::RemoveHandler, XrdCl::stError, and XrdCl::MsgHandler::Timeout.

Referenced by XrdCl::Stream::Tick().

+ Here is the caller graph for this function:

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