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, bool &rmMsg)
void | AssignTimeout (MsgHandler *handler)
MsgHandler * | GetHandlerForMessage (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,
|  | bool & | rmMsg )

Add a listener that should be notified about incoming messages. Freshly added handlers have no expire time set and will not trigger the timeout reporting. The expiry is added by AssignTimeout or GetHandlerForMessage.

Parameters

  handler | message handler
  rmMsg | will 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.

{
uint16_t handlerSid = handler->GetSid();
XrdSysMutexHelper scopedLock( pMutex );
pHandlers[handlerSid] = HandlerAndExpire( handler, 0 );
}

References XrdCl::MsgHandler::GetSid().

Here is the call graph for this function:

## AssignTimeout()

void XrdCl::InQueue::AssignTimeout | ( | MsgHandler * | handler | ) |

If the specified handler is in the queue but has not yet had an expiry time assigned, query the handler for the expiry and record it. Expiry will also be assigned by GetHandlerForMessage if not already assigned.

Parameters

  handler | handler to check

Definition at line 192 of file XrdClInQueue.cc.

{
uint16_t handlerSid = handler->GetSid();
XrdSysMutexHelper scopedLock( pMutex );
HandlerMap::iterator it = pHandlers.find( handlerSid );
if( it != pHandlers.end() )
{
if( it->second.second == 0 )
{
it->second.second = handler->GetExpiration();
Log *log = DefaultEnv::GetLog();
log->Debug( ExDbgMsg, "[handler: %p] Assigned expiration %lld.",
(void*)handler, (long long)it->second.second );
}
}
}
XrdCl::DefaultEnv::GetLog
static Log * GetLog()
Get default log.
Definition XrdClDefaultEnv.cc:493
XrdCl::ExDbgMsg
const uint64_t ExDbgMsg
Definition XrdClConstants.hh:44
XrdGlobal::Log
XrdSysError Log
Definition XrdConfig.cc:113

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

Here is the call 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

  msg | message header
  expires | handle's expiration timestamp
  action | the action declared by the handler

Returns
  handler or 0 if none is interested

Definition at line 66 of file XrdClInQueue.cc.

{
time_t exp = 0;
uint16_t act = 0;
uint16_t msgSid = 0;
MsgHandler* handler = 0;
if (DiscardMessage(*msg, msgSid))
{
return handler;
}
XrdSysMutexHelper scopedLock( pMutex );
HandlerMap::iterator it = pHandlers.find(msgSid);
if (it != pHandlers.end())
{
Log *log = DefaultEnv::GetLog();
handler = it->second.first;
act = handler->Examine( msg );
if( it->second.second == 0 ) {
it->second.second = handler->GetExpiration();
log->Debug( ExDbgMsg, "[handler: %p] Assigned expiration %lld.",
(void*)handler, (long long)it->second.second );
}
exp = it->second.second;
log->Debug( ExDbgMsg, "[msg: %p] Assigned MsgHandler: %p.",
(void*)msg.get(), (void*)handler );
if( act & MsgHandler::RemoveHandler )
{
pHandlers.erase( it );
log->Debug( ExDbgMsg, "[handler: %p] Removed MsgHandler: %p from the in-queue.",
(void*)handler, (void*)handler );
}
}
if( handler )
{
expires = exp;
action = act;
}
return handler;
}
XrdCl::MsgHandler::RemoveHandler
@ RemoveHandler
Definition XrdClPostMasterInterfaces.hh:61

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

Here is the call 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 118 of file XrdClInQueue.cc.

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

References XrdCl::MsgHandler::GetSid().

Here is the call graph for this function:

## RemoveMessageHandler()

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

Remove a listener.

Definition at line 129 of file XrdClInQueue.cc.

{
uint16_t handlerSid = handler->GetSid();
XrdSysMutexHelper scopedLock( pMutex );
pHandlers.erase(handlerSid);
Log *log = DefaultEnv::GetLog();
log->Debug( ExDbgMsg, "[handler: %p] Removed MsgHandler: %p from the in-queue.",
(void*)handler, (void*)handler );
}

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

Here is the call graph for this function:

## ReportStreamEvent()

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

Report an event to the handlers.

Definition at line 143 of file XrdClInQueue.cc.

{
uint8_t action = 0;
XrdSysMutexHelper scopedLock( pMutex );
for( HandlerMap::iterator it = pHandlers.begin(); it != pHandlers.end(); )
{
action = it->second.first->OnStreamEvent( event, status );
if( action & MsgHandler::RemoveHandler )
{
auto next = it; ++next;
pHandlers.erase( it );
it = next;
}
else
++it;
}
}

References XrdCl::MsgHandler::RemoveHandler.

## ReportTimeout()

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

Timeout handlers.

Definition at line 166 of file XrdClInQueue.cc.

{
if( !now )
now = ::time(0);
XrdSysMutexHelper scopedLock( pMutex );
HandlerMap::iterator it = pHandlers.begin();
while( it != pHandlers.end() )
{
if( it->second.second && it->second.second <= now )
{
uint8_t act = it->second.first->OnStreamEvent( MsgHandler::Timeout,
Status( stError, errOperationExpired ) );
auto next = it; ++next;
if( act & MsgHandler::RemoveHandler )
pHandlers.erase( it );
it = next;
}
else
++it;
}
}
XrdCl::MsgHandler::Timeout
@ Timeout
The declared timeout has occurred.
Definition XrdClPostMasterInterfaces.hh:82
XrdCl::errOperationExpired
const uint16_t errOperationExpired
Definition XrdClStatus.hh:90
XrdCl::stError
const uint16_t stError
An error occurred that could potentially be retried.
Definition XrdClStatus.hh:32

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

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

- XrdClInQueue.hh
- XrdClInQueue.cc