30 static SIDMgrPool *instance =
new SIDMgrPool();
40 uint16_t allocSID = 1;
45 if( !pFreeSIDs.empty() )
47 allocSID = pFreeSIDs.front();
48 pFreeSIDs.pop_front();
55 if( pSIDCeiling == 0xffff )
57 allocSID = pSIDCeiling++;
60 memcpy( sid, &allocSID, 2 );
61 pAllocTime[allocSID] = time(0);
72 memcpy( &relSID, sid, 2 );
73 pFreeSIDs.push_back( relSID );
74 pAllocTime.erase( relSID );
84 memcpy( &tiSID, sid, 2 );
85 pTimeOutSIDs.insert( tiSID );
86 pAllocTime.erase( tiSID );
95 return std::any_of( pAllocTime.begin(), pAllocTime.end(),
98 return p.second <= tlim;
109 memcpy( &tiSID, sid, 2 );
110 std::set<uint16_t>::iterator it = pTimeOutSIDs.find( tiSID );
111 if( it != pTimeOutSIDs.end() )
123 memcpy( &tiSID, sid, 2 );
124 pTimeOutSIDs.erase( tiSID );
125 pFreeSIDs.push_back( tiSID );
134 std::set<uint16_t>::iterator it;
135 for( it = pTimeOutSIDs.begin(); it != pTimeOutSIDs.end(); ++it )
136 pFreeSIDs.push_back( *it );
137 pTimeOutSIDs.clear();
146 return pSIDCeiling - pFreeSIDs.size() - pTimeOutSIDs.size() - 1;
160 if( itr == pool.end() )
165 else mgr = itr->second;
176 RecycleSidMgr deleter;
177 std::shared_ptr<SIDManager> ptr( mgr, deleter );
195 if( !mgr->pRefCount )
200 auto itr = pool.begin();
201 for( ; itr != pool.end() ; ++itr )
202 if( itr->second == mgr )
Handle XRootD stream IDs.
void ReleaseTimedOut(uint8_t sid[2])
Release a timed out SID.
uint16_t GetNumberOfAllocatedSIDs() const
Number of allocated streams.
void TimeOutSID(uint8_t sid[2])
Register a SID of a request that timed out.
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.
Status AllocateSID(uint8_t sid[2])
void ReleaseAllTimedOut()
Release all timed out SIDs.
void ReleaseSID(uint8_t sid[2])
Release the SID that is no longer needed.
static SIDMgrPool & Instance()
void Recycle(SIDManager *mgr)
std::shared_ptr< SIDManager > GetSIDMgr(const URL &url)
std::string GetChannelId() const
const uint16_t stError
An error occurred that could potentially be retried.
const uint16_t errNoMoreFreeSIDs
Procedure execution status.