XRootD
XrdCl::SIDMgrPool Class Reference

Pool of SID manager objects. More...

#include <XrdClSIDManager.hh>

+ Collaboration diagram for XrdCl::SIDMgrPool:

Public Member Functions

 ~SIDMgrPool ()
 Destructor. More...
 
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 144 of file XrdClSIDManager.hh.

144 { }

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 152 of file XrdClSIDManager.cc.

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

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 ( )
static
Returns
: instance of SIDMgrPool

Definition at line 25 of file XrdClSIDManager.cc.

26  {
27  //----------------------------------------------------------------------
28  // We could also use a nifty counter but this is simpler and will do!
29  //----------------------------------------------------------------------
30  static SIDMgrPool *instance = new SIDMgrPool();
31  return *instance;
32  }

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 182 of file XrdClSIDManager.cc.

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

References XrdSysMutexHelper::UnLock().

+ Here is the call graph for this function:

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