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

Pool of SID manager objects. More...

#include <XrdClSIDManager.hh>

Collaboration diagram for XrdCl::SIDMgrPool:

Public Member Functions

 ~SIDMgrPool ()
 Destructor.
std::shared_ptr< SIDManagerGetSIDMgr (const URL &url)
void Recycle (SIDManager *mgr)

Static Public Member Functions

static SIDMgrPoolInstance ()

Detailed Description

Pool of SID manager objects.

Definition at line 132 of file XrdClSIDManager.hh.

Constructor & Destructor Documentation

◆ ~SIDMgrPool()

XrdCl::SIDMgrPool::~SIDMgrPool ( )
inline

Destructor.

Definition at line 151 of file XrdClSIDManager.hh.

151{ }

Member Function Documentation

◆ GetSIDMgr()

std::shared_ptr< SIDManager > XrdCl::SIDMgrPool::GetSIDMgr ( const URL & url)
Parameters
url: URL for which we need a SIDManager
Returns
: a shared pointer to SIDManager object, the pointer has

Definition at line 144 of file XrdClSIDManager.cc.

145 {
146 //--------------------------------------------------------------------------
147 // Look for an instance of SID manager in the pool
148 //--------------------------------------------------------------------------
149 XrdSysMutexHelper lck1( mtx );
150 SIDManager *mgr = 0;
151 auto itr = pool.find( url.GetChannelId() );
152 if( itr == pool.end() )
153 {
154 mgr = new SIDManager();
155 pool[url.GetChannelId()] = mgr;
156 }
157 else mgr = itr->second;
158
159 //--------------------------------------------------------------------------
160 // Update the reference counter
161 //--------------------------------------------------------------------------
162 XrdSysMutexHelper lck2( mgr->pMutex );
163 ++mgr->pRefCount;
164
165 //--------------------------------------------------------------------------
166 // Create a shared pointer that will recycle the SID manager
167 //--------------------------------------------------------------------------
168 RecycleSidMgr deleter;
169 std::shared_ptr<SIDManager> ptr( mgr, deleter );
170
171 return ptr;
172 }

References XrdCl::URL::GetChannelId().

Referenced by XrdCl::XRootDChannelInfo::XRootDChannelInfo().

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

◆ Instance()

SIDMgrPool & XrdCl::SIDMgrPool::Instance ( )
inlinestatic
Returns
: instance of SIDMgrPool

Definition at line 139 of file XrdClSIDManager.hh.

140 {
141 //----------------------------------------------------------------------
142 // We could also use a nifty counter but this is simpler and will do!
143 //----------------------------------------------------------------------
144 static SIDMgrPool *instance = new SIDMgrPool();
145 return *instance;
146 }

Referenced by XrdCl::XRootDChannelInfo::XRootDChannelInfo(), and XrdCl::MessageUtils::SendMessage().

Here is the caller graph for this function:

◆ Recycle()

void XrdCl::SIDMgrPool::Recycle ( SIDManager * mgr)
Parameters
mgr: the SIDManager object to be recycled

Definition at line 174 of file XrdClSIDManager.cc.

175 {
176 //--------------------------------------------------------------------------
177 // Lock the pool, we need to do it in the same order as in 'GetSIDMgr'
178 //--------------------------------------------------------------------------
179 XrdSysMutexHelper lck1( mtx );
180
181 //--------------------------------------------------------------------------
182 // Lock the SID manager object
183 //--------------------------------------------------------------------------
184 XrdSysMutexHelper lck2( mgr->pMutex );
185 --mgr->pRefCount;
186
187 if( !mgr->pRefCount )
188 {
189 //------------------------------------------------------------------------
190 // Remove the SID manager from the pool
191 //------------------------------------------------------------------------
192 auto itr = pool.begin();
193 for( ; itr != pool.end() ; ++itr )
194 if( itr->second == mgr )
195 {
196 pool.erase( itr );
197 break;
198 }
199
200 lck2.UnLock();
201 delete mgr;
202 }
203 }

References XrdSysMutexHelper::UnLock().

Here is the call graph for this function:

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