MCPcopy Create free account
hub / github.com/apache/trafficserver / loadObjects

Method loadObjects

plugins/esi/lib/HandlerManager.cc:43–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41const char *const HandlerManager::FACTORY_FUNCTION_NAME = "createSpecialIncludeHandler";
42
43void
44HandlerManager::loadObjects(const Utils::KeyValueMap &handlers)
45{
46 ModuleHandleMap::iterator path_map_iter;
47
48 for (Utils::KeyValueMap::const_iterator id_map_iter = handlers.begin(); id_map_iter != handlers.end(); ++id_map_iter) {
49 const string &id = id_map_iter->first;
50 const string &path = id_map_iter->second;
51
52 path_map_iter = _path_to_module_map.find(path);
53
54 if (path_map_iter != _path_to_module_map.end()) {
55 // we have already loaded this object; just point id to original handle
56 _id_to_function_map.insert(FunctionHandleMap::value_type(id, (path_map_iter->second).function));
57 } else {
58 // no, we have to load this object
59 void *obj_handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_LOCAL);
60 if (!obj_handle) {
61 TSError("[%s::%s] Could not load module [%s]. Error [%s]", CLASS_NAME, __FUNCTION__, path.c_str(), dlerror());
62 } else {
63 SpecialIncludeHandlerCreator func_handle = (SpecialIncludeHandlerCreator)(dlsym(obj_handle, FACTORY_FUNCTION_NAME));
64 if (!func_handle) {
65 TSError("[%s::%s] Could not find factory function [%s] in module [%s]. Error [%s]", CLASS_NAME, __FUNCTION__,
66 FACTORY_FUNCTION_NAME, path.c_str(), dlerror());
67 dlclose(obj_handle);
68 } else {
69 _id_to_function_map.insert(FunctionHandleMap::value_type(id, func_handle));
70 _path_to_module_map.insert(ModuleHandleMap::value_type(path, ModuleHandles(obj_handle, func_handle)));
71 Dbg(dbg_ctl, "[%s] Loaded handler module [%s]", __FUNCTION__, path.c_str());
72 }
73 }
74 }
75 }
76}
77
78SpecialIncludeHandler *
79HandlerManager::getHandler(Variables &esi_vars, Expression &esi_expr, HttpDataFetcher &fetcher, const std::string &id) const

Callers 1

esiPluginInitFunction · 0.45

Calls 7

ModuleHandlesClass · 0.85
TSErrorFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
insertMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected