SNode.C
Loading...
Searching...
No Matches
core::DynamicLoader Class Reference

#include <DynamicLoader.h>

Collaboration diagram for core::DynamicLoader:

Classes

struct  Library
 

Public Member Functions

 DynamicLoader ()=delete
 
 ~DynamicLoader ()=delete
 

Static Public Member Functions

static void * dlRegisterHandle (void *handle, const std::string &libFile)
 
static void dlCloseDelayed (void *handle)
 
static int dlClose (void *handle)
 
static void * dlSym (void *handle, const std::string &symbol)
 
static char * dlError ()
 

Static Private Member Functions

static int dlClose (const Library &library)
 
static int realExecDlClose (const Library &library)
 
static void execDlCloseDeleyed ()
 
static void execDlCloseAll ()
 

Static Private Attributes

static std::map< void *, LibrarydlOpenedLibraries
 
static std::list< void * > closeHandles
 

Friends

class EventLoop
 
class EventMultiplexer
 

Detailed Description

Definition at line 57 of file DynamicLoader.h.

Constructor & Destructor Documentation

◆ DynamicLoader()

core::DynamicLoader::DynamicLoader ( )
delete

◆ ~DynamicLoader()

core::DynamicLoader::~DynamicLoader ( )
delete

Member Function Documentation

◆ dlClose() [1/2]

int core::DynamicLoader::dlClose ( const Library library)
staticprivate

Definition at line 119 of file DynamicLoader.cpp.

119 {
120 int ret = 0;
121 ret = realExecDlClose(library);
122
123 if (ret != 0) {
124 LOG(TRACE) << " dlClose: " << DynamicLoader::dlError();
125 } else {
126 LOG(TRACE) << " dlClose: " << library.fileName << ": success";
127 }
128
129 return ret;
130 }
static char * dlError()
static int realExecDlClose(const Library &library)

References dlError(), core::DynamicLoader::Library::fileName, and realExecDlClose().

Referenced by dlClose(), execDlCloseAll(), and execDlCloseDeleyed().

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

◆ dlClose() [2/2]

int core::DynamicLoader::dlClose ( void *  handle)
static

Definition at line 89 of file DynamicLoader.cpp.

89 {
90 int ret = 0;
91
92 if (handle != nullptr) {
93 if (dlOpenedLibraries.contains(handle)) {
94 ret = dlClose(dlOpenedLibraries[handle]);
95
96 dlOpenedLibraries.erase(handle);
97 } else {
98 LOG(TRACE) << "DynLoader: dlCloseDelayed: " << handle << ": not opened using dlOpen";
99 }
100 } else {
101 LOG(TRACE) << "DynLoader: dlClose handle: nullptr";
102 }
103
104 return ret;
105 }
static int dlClose(void *handle)
static std::map< void *, Library > dlOpenedLibraries

References dlClose(), and dlOpenedLibraries.

Referenced by web::websocket::SubProtocolFactorySelector< web::websocket::SubProtocolFactory< web::websocket::client::SubProtocol > >::load().

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

◆ dlCloseDelayed()

void core::DynamicLoader::dlCloseDelayed ( void *  handle)
static

Definition at line 71 of file DynamicLoader.cpp.

71 {
72 if (handle != nullptr) {
73 if (dlOpenedLibraries.contains(handle)) {
74 if (std::find(closeHandles.begin(), closeHandles.end(), handle) == closeHandles.end()) {
75 LOG(TRACE) << "DynLoader: dlCloseDelayed: " << dlOpenedLibraries[handle].fileName;
76
77 closeHandles.push_back(handle);
78 } else {
79 LOG(TRACE) << "DynLoader: dlCloseDelayed: " << dlOpenedLibraries[handle].fileName << ": already registered: ";
80 }
81 } else {
82 LOG(TRACE) << "DynLoader: dlCloseDelayed: " << handle << ": not opened using dlOpen";
83 }
84 } else {
85 LOG(TRACE) << "DynLoader: dlCloseDelayed: handle is nullptr";
86 }
87 }
static std::list< void * > closeHandles

References closeHandles, dlOpenedLibraries, and core::DynamicLoader::Library::fileName.

Referenced by web::http::SocketContextUpgradeFactorySelector< SocketContextUpgradeFactoryT >::unload(), and web::websocket::SubProtocolFactorySelector< SubProtocolFactoryT >::unload().

Here is the caller graph for this function:

◆ dlError()

char * core::DynamicLoader::dlError ( )
static

Definition at line 111 of file DynamicLoader.cpp.

111 {
112 return core::system::dlerror();
113 }
char * dlerror()
Definition dlfcn.cpp:67

References core::system::dlerror().

Referenced by dlClose(), and dlRegisterHandle().

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

◆ dlRegisterHandle()

void * core::DynamicLoader::dlRegisterHandle ( void *  handle,
const std::string &  libFile 
)
static

Definition at line 57 of file DynamicLoader.cpp.

57 {
58 if (handle != nullptr) {
59 if (!dlOpenedLibraries.contains(handle)) {
60 dlOpenedLibraries[handle].fileName = libFile;
61 dlOpenedLibraries[handle].handle = handle;
62 }
63 LOG(TRACE) << "DynLoader: dlOpen: " << libFile << ": success";
64 } else {
65 LOG(TRACE) << "DynLoader: dlOpen: " << DynamicLoader::dlError();
66 }
67
68 return handle;
69 }

References dlError(), dlOpenedLibraries, core::DynamicLoader::Library::fileName, and core::DynamicLoader::Library::handle.

Here is the call graph for this function:

◆ dlSym()

void * core::DynamicLoader::dlSym ( void *  handle,
const std::string &  symbol 
)
static

Definition at line 107 of file DynamicLoader.cpp.

107 {
108 return core::system::dlsym(handle, symbol.c_str());
109 }
void * dlsym(void *handle, const char *symbol)
Definition dlfcn.cpp:62

References core::system::dlsym().

Referenced by web::websocket::SubProtocolFactorySelector< SubProtocolFactoryT >::load().

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

◆ execDlCloseAll()

void core::DynamicLoader::execDlCloseAll ( )
staticprivate

Definition at line 147 of file DynamicLoader.cpp.

147 {
148 LOG(TRACE) << "DynLoader: execDlCloseAll";
149
150 for (auto& [handle, library] : dlOpenedLibraries) {
151 dlClose(library);
152 }
153
154 dlOpenedLibraries.clear();
155 closeHandles.clear();
156
157 LOG(TRACE) << "DynLoader: execDlCloseAll done";
158 }

References closeHandles, dlClose(), and dlOpenedLibraries.

Referenced by core::EventLoop::free().

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

◆ execDlCloseDeleyed()

void core::DynamicLoader::execDlCloseDeleyed ( )
staticprivate

Definition at line 132 of file DynamicLoader.cpp.

132 {
133 if (!closeHandles.empty()) {
134 LOG(TRACE) << "DynLoader: execDlCloseDeleyed";
135
136 for (void* handle : closeHandles) {
137 dlClose(dlOpenedLibraries[handle]);
138 dlOpenedLibraries.erase(handle);
139 }
140
141 closeHandles.clear();
142
143 LOG(TRACE) << "DynLoader: execDlCloseDeleyed done";
144 }
145 }

References closeHandles, dlClose(), and dlOpenedLibraries.

Referenced by core::EventMultiplexer::releaseExpiredResources().

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

◆ realExecDlClose()

int core::DynamicLoader::realExecDlClose ( const Library library)
staticprivate

Definition at line 115 of file DynamicLoader.cpp.

115 {
116 return core::system::dlclose(library.handle);
117 }
int dlclose(void *handle)
Definition dlfcn.cpp:57

References core::system::dlclose(), and core::DynamicLoader::Library::handle.

Referenced by dlClose().

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

Friends And Related Symbol Documentation

◆ EventLoop

friend class EventLoop
friend

Definition at line 86 of file DynamicLoader.h.

◆ EventMultiplexer

friend class EventMultiplexer
friend

Definition at line 87 of file DynamicLoader.h.

Member Data Documentation

◆ closeHandles

std::list< void * > core::DynamicLoader::closeHandles
staticprivate

Definition at line 84 of file DynamicLoader.h.

Referenced by dlCloseDelayed(), execDlCloseAll(), and execDlCloseDeleyed().

◆ dlOpenedLibraries

std::map< void *, DynamicLoader::Library > core::DynamicLoader::dlOpenedLibraries
staticprivate

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