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

Handle XRootD stream IDs. More...

`#include <XrdClSIDManager.hh>`

Collaboration diagram for XrdCl::SIDManager:

## Public Member Functions

| ~SIDManager ()
| Destructor.
Status | AllocateSID (uint8_t sid[2])
uint16_t | GetNumberOfAllocatedSIDs () const
| Number of allocated streams.
bool | IsAnySIDOldAs (const time_t tlim) const
| Check if any SID was allocated at or before a given time.
bool | IsTimedOut (uint8_t sid[2])
| Check if a SID is timed out.
uint32_t | NumberOfTimedOutSIDs () const
| Number of timeout sids.
void | ReleaseAllTimedOut ()
| Release all timed out SIDs.
void | ReleaseSID (uint8_t sid[2])
| Release the SID that is no longer needed.
void | ReleaseTimedOut (uint8_t sid[2])
| Release a timed out SID.
void | TimeOutSID (uint8_t sid[2])
| Register a SID of a request that timed out.

## Friends

class | SIDMgrPool

## Detailed Description

Handle XRootD stream IDs.

Definition at line 42 of file XrdClSIDManager.hh.

## Constructor & Destructor Documentation

## ~SIDManager()

XrdCl::SIDManager::~SIDManager | ( |  | ) |

inline

Destructor.

Definition at line 64 of file XrdClSIDManager.hh.

{ }

## Member Function Documentation

## AllocateSID()

Status XrdCl::SIDManager::AllocateSID | ( | uint8_t | sid[2] | ) |

Allocate a SID

Parameters

  sid | a two byte array where the allocated SID should be stored

Returns
  stOK on success, stError on error

Definition at line 28 of file XrdClSIDManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
uint16_t allocSID = 1;
//--------------------------------------------------------------------------
// Get a SID from the list of free SIDs if it's not empty
//--------------------------------------------------------------------------
if( !pFreeSIDs.empty() )
{
allocSID = pFreeSIDs.front();
pFreeSIDs.pop_front();
}
//--------------------------------------------------------------------------
// Allocate a new SID if possible
//--------------------------------------------------------------------------
else
{
if( pSIDCeiling == 0xffff )
return Status( stError, errNoMoreFreeSIDs );
allocSID = pSIDCeiling++;
}
memcpy( sid, &allocSID, 2 );
pAllocTime[allocSID] = time(0);
return Status();
}
XrdCl::stError
const uint16_t stError
An error occurred that could potentially be retried.
Definition XrdClStatus.hh:32
XrdCl::errNoMoreFreeSIDs
const uint16_t errNoMoreFreeSIDs
Definition XrdClStatus.hh:97

References XrdCl::errNoMoreFreeSIDs, and XrdCl::stError.

## GetNumberOfAllocatedSIDs()

uint16_t XrdCl::SIDManager::GetNumberOfAllocatedSIDs | ( |  | ) | const

Number of allocated streams.

Definition at line 135 of file XrdClSIDManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
return pSIDCeiling - pFreeSIDs.size() - pTimeOutSIDs.size() - 1;
}

## IsAnySIDOldAs()

bool XrdCl::SIDManager::IsAnySIDOldAs | ( | const time_t | tlim | ) | const

Check if any SID was allocated at or before a given time.

Definition at line 84 of file XrdClSIDManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
return std::any_of( pAllocTime.begin(), pAllocTime.end(),
[tlim](const auto& p)
{
return p.second <= tlim;
} );
}

## IsTimedOut()

bool XrdCl::SIDManager::IsTimedOut | ( | uint8_t | sid[2] | ) |

Check if a SID is timed out.

Definition at line 97 of file XrdClSIDManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
uint16_t tiSID = 0;
memcpy( &tiSID, sid, 2 );
std::set<uint16_t>::iterator it = pTimeOutSIDs.find( tiSID );
if( it != pTimeOutSIDs.end() )
return true;
return false;
}

## NumberOfTimedOutSIDs()

uint32_t XrdCl::SIDManager::NumberOfTimedOutSIDs | ( |  | ) | const

inline

Number of timeout sids.

Definition at line 109 of file XrdClSIDManager.hh.

{
XrdSysMutexHelper scopedLock( pMutex );
return pTimeOutSIDs.size();
}

## ReleaseAllTimedOut()

void XrdCl::SIDManager::ReleaseAllTimedOut | ( |  | ) |

Release all timed out SIDs.

Definition at line 123 of file XrdClSIDManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
std::set<uint16_t>::iterator it;
for( it = pTimeOutSIDs.begin(); it != pTimeOutSIDs.end(); ++it )
pFreeSIDs.push_back( *it );
pTimeOutSIDs.clear();
}

## ReleaseSID()

void XrdCl::SIDManager::ReleaseSID | ( | uint8_t | sid[2] | ) |

Release the SID that is no longer needed.

Definition at line 60 of file XrdClSIDManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
uint16_t relSID = 0;
memcpy( &relSID, sid, 2 );
pFreeSIDs.push_back( relSID );
pAllocTime.erase( relSID );
}

## ReleaseTimedOut()

void XrdCl::SIDManager::ReleaseTimedOut | ( | uint8_t | sid[2] | ) |

Release a timed out SID.

Definition at line 111 of file XrdClSIDManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
uint16_t tiSID = 0;
memcpy( &tiSID, sid, 2 );
pTimeOutSIDs.erase( tiSID );
pFreeSIDs.push_back( tiSID );
}

## TimeOutSID()

void XrdCl::SIDManager::TimeOutSID | ( | uint8_t | sid[2] | ) |

Register a SID of a request that timed out.

Definition at line 72 of file XrdClSIDManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
uint16_t tiSID = 0;
memcpy( &tiSID, sid, 2 );
pTimeOutSIDs.insert( tiSID );
pAllocTime.erase( tiSID );
}

## Friends And Related Symbol Documentation

## SIDMgrPool

friend class SIDMgrPool

friend

Definition at line 44 of file XrdClSIDManager.hh.

References SIDMgrPool.

Referenced by SIDMgrPool.

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

- XrdClSIDManager.hh
- XrdClSIDManager.cc