XRootD
XrdOucPinLoader Class Reference

#include <XrdOucPinLoader.hh>

+ Collaboration diagram for XrdOucPinLoader:

Public Member Functions

 XrdOucPinLoader (char *eBuff, int eBlen, XrdVersionInfo *vInfo, const char *drctv, const char *plib)
 
 XrdOucPinLoader (XrdSysError *errP, XrdVersionInfo *vInfo, const char *drctv, const char *plib)
 
 XrdOucPinLoader (XrdVersionInfo *vInfo, const char *drctv, const char *plib)
 
 ~XrdOucPinLoader ()
 
XrdSysPluginExport ()
 
void Global (bool glbl)
 
const char * LastMsg ()
 
const char * Path ()
 
void * Resolve (const char *symbl, int mcnt=1)
 
void Unload (bool dodel=false)
 

Detailed Description

Definition at line 49 of file XrdOucPinLoader.hh.

Constructor & Destructor Documentation

◆ XrdOucPinLoader() [1/3]

XrdOucPinLoader::XrdOucPinLoader ( XrdSysError errP,
XrdVersionInfo *  vInfo,
const char *  drctv,
const char *  plib 
)

Constructor #1

Parameters
errPPointer to the message routing object.
vInfoPointer to the version information of the caller. If the pointer is nil, no version checking occurs.
drctvPointer to the directive that initiated the load. The text is used in error messages to relate the directive to the error. E.g. "ofs.osslib" -> "Unable to load ofs.osslib plugin...."
plibPointer to the shared library path that contains the plugin.

Definition at line 46 of file XrdOucPinLoader.cc.

50 {
51 
52 // Save some symbols and do common initialization
53 //
54  eDest = errP;
55  viP = vInfo;
56  errBP = 0;
57  errBL = 0;
58  Init(drctv, plib);
59 }

◆ XrdOucPinLoader() [2/3]

XrdOucPinLoader::XrdOucPinLoader ( char *  eBuff,
int  eBlen,
XrdVersionInfo *  vInfo,
const char *  drctv,
const char *  plib 
)

Constructor #2

Parameters
eBuffPointer to a buffer to receive messages.
eBlenLength of the buffer.
vInfoPointer to the version information of the caller. If the pointer is nil, no version checking occurs.
drctvPointer to the directive that initiated the load (see above).
plibPointer to the shared library path that contains the plugin.

Definition at line 63 of file XrdOucPinLoader.cc.

68 {
69 
70 // Save some symbols and do common initialization
71 //
72  eDest = 0;
73  viP = vInfo;
74  errBP = (eBlen > 0 ? eBuff : 0);
75  errBL = (eBlen > 0 ? eBlen : 0);
76  frBuff= false;
77  if (errBP) *errBP = 0;
78  Init(drctv, plib);
79 }

◆ XrdOucPinLoader() [3/3]

XrdOucPinLoader::XrdOucPinLoader ( XrdVersionInfo *  vInfo,
const char *  drctv,
const char *  plib 
)

Constructor #3 (An internal message buffer is allocated. You can get the message, if any, using LastMsg())

Parameters
vInfoPointer to the version information of the caller. If the pointer is nil, no version checking occurs.
drctvPointer to the directive that initiated the load (see above).
plibPointer to the shared library path that contains the plugin.

Definition at line 83 of file XrdOucPinLoader.cc.

86 {
87  static const int ebsz = 2048;
88 
89 // Allocate a message buffer if we need to (failure is OK)
90 //
91  errBP = (char *)malloc(ebsz);
92  errBL = ebsz;
93  frBuff= true;
94 
95 // Save some symbols and do common initialization
96 //
97  *errBP= 0;
98  eDest = 0;
99  viP = vInfo;
100  Init(drctv, plib);
101 }

◆ ~XrdOucPinLoader()

XrdOucPinLoader::~XrdOucPinLoader ( )

Destructor

Upon deletion, if the plugin was successfully loaded, it is persisted.

Definition at line 107 of file XrdOucPinLoader.cc.

108 {
109 
110 // Releae storage
111 //
112  if (theLib) free(theLib);
113  if (altLib) free(altLib);
114 
115 // Persist the image if we have one
116 //
117  if (piP) {piP->Persist(); delete piP;}
118  if (errBP && frBuff) free(errBP);
119 }
void * Persist()

References XrdSysPlugin::Persist().

+ Here is the call graph for this function:

Member Function Documentation

◆ Export()

XrdSysPlugin* XrdOucPinLoader::Export ( )
inline

Export the plugin object for manual management.

Returns
!0 Pointer to the plugin object. It is disassociated from this object and must be manually managed.
=0 Either no plugin object has been created or it has been exported.

Definition at line 62 of file XrdOucPinLoader.hh.

62 {XrdSysPlugin *tmp = piP; piP = 0; return tmp;}

Referenced by XrdCksLoader::Load().

+ Here is the caller graph for this function:

◆ Global()

void XrdOucPinLoader::Global ( bool  glbl)
inline

Set export range of symbols in the plugin.

Parameters
glblwhen true then the symbols defined in the plug-in shared library are made available for symbol resolution of subsequently loaded libraries.

Definition at line 72 of file XrdOucPinLoader.hh.

72 {global = glbl;}

◆ LastMsg()

const char* XrdOucPinLoader::LastMsg ( )
inline

Get the last message placed in the buffer.

Returns
Pointer to the last message. If there is no buffer or no message exists, a null string is returned.

Definition at line 81 of file XrdOucPinLoader.hh.

81 {return (errBP ? errBP : "");}

Referenced by XrdCryptoFactory::GetCryptoFactory().

+ Here is the caller graph for this function:

◆ Path()

const char* XrdOucPinLoader::Path ( )
inline

Get the actual path that was or will tried for loading.

Returns
Pointer to the path that was loaded if called after Resolve() or the path that will be attempted to be loaded. If the path is invalid, a single question mark is returned.

Definition at line 91 of file XrdOucPinLoader.hh.

91 {return theLib;}

Referenced by XrdOssGetSS().

+ Here is the caller graph for this function:

◆ Resolve()

void * XrdOucPinLoader::Resolve ( const char *  symbl,
int  mcnt = 1 
)

Resolve a desired symbol from the plugin image.

Parameters
symblPointer to the name of the symbol to resolve.
mcntMaximum number of version messages to be displayed.
Returns
!0 The address of the symbol.
=0 The symbol could not be resolved.

Definition at line 267 of file XrdOucPinLoader.cc.

268 {
269  int isOptional = 0;
270 
271 // Check if we couldn't create the path
272 //
273  if (!theLib && !badLib)
274  {Inform("Unable to load ",dName," plugin ",altLib,"; invalid path.");
275  badLib = true;
276  return 0;
277  }
278 
279 // If we couldn't load the library return failure. This is likely an alternate
280 // resolution as the caller is looking for an alternate symbol.
281 //
282  if (badLib) return 0;
283 
284 // Load the library so we can get errors about the library irrespective of
285 // the symbol we are trying to resolve.
286 //
287  if (!piP && !LoadLib(mcnt)) return 0;
288 
289 // Handle optional resolution
290 //
291  if (*symP == '?' || *symP == '!')
292  {symP++;
293  isOptional = (*symP == '!' ? 1 : 2);
294  }
295 
296 // We already have a plugin object so look up the symbol.
297 //
298  return piP->getPlugin(symP, isOptional, global);
299 }
void * getPlugin(const char *pname, int optional=0)

References XrdSysPlugin::getPlugin().

Referenced by XrdOucLogging::configLog(), XrdOssSys::ConfigStatLib(), XrdCryptoFactory::GetCryptoFactory(), XrdCl::DefaultEnv::GetMonitor(), XrdCmsSecurity::getVnId(), XrdCksLoader::Load(), XrdOucN2NLoader::Load(), XrdCmsUtils::loadPerfMon(), XrdOssGetSS(), and XrdXrootdloadFileSystem().

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

◆ Unload()

void XrdOucPinLoader::Unload ( bool  dodel = false)

Unload any plugin that may be associated with this object. The plugin image will not be persisted when this object is deleted.

Parameters
dodelWhen true, the object is deleted (this only works if it is created via new). Otherwise, plugin is only unloaded.

Definition at line 305 of file XrdOucPinLoader.cc.

306 {
307 
308 // Simply delete any plugin object
309 //
310  if (piP) {delete piP; piP = 0;}
311  if (dodel) delete this;
312 }

Referenced by XrdOucLogging::configLog(), XrdCl::DefaultEnv::GetMonitor(), XrdCmsSecurity::getVnId(), and XrdCksLoader::Load().

+ Here is the caller graph for this function:

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