Loading src/plugin/PluginManager.cpp +7 −2 Changes for src/plugin/PluginManager.cpp: 7 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -26,16 +26,16 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st struct dirent *entry; while ((entry = ::readdir(d)) != nullptr) { std::string fname = entry->d_name; std::cout << "[plugin] checking " << fname << std::endl; if (fname.size() < 3 || fname.substr(fname.size() - 3) != ".so") continue; std::string path = dir + "/" + fname; std::cout << "[plugin] loading " << path << std::endl; void *handle = ::dlopen(path.c_str(), RTLD_NOW | RTLD_LOCAL); if (!handle) { std::cerr << "[plugin] " << fname << ": dlopen failed: " << (::dlerror() ? ::dlerror() : "unknown error") << std::endl; _errors.push_back(fname + ": " + std::string(::dlerror() ? ::dlerror() : "dlopen failed")); continue; } Loading @@ -47,11 +47,14 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st reinterpret_cast<void (*)(IPlugin *)>(::dlsym(handle, "proxyplus_plugin_destroy")); if (!abiFn || !createFn || !destroyFn) { std::cerr << "[plugin] " << fname << ": missing required plugin ABI symbols" << std::endl; _errors.push_back(fname + ": missing required plugin ABI symbols"); ::dlclose(handle); continue; } if (abiFn() != PROXYPLUS_PLUGIN_ABI_VERSION) { std::cerr << "[plugin] " << fname << ": ABI version mismatch (plugin=" << abiFn() << ", host=" << PROXYPLUS_PLUGIN_ABI_VERSION << ")" << std::endl; _errors.push_back(fname + ": ABI version mismatch (plugin=" + std::to_string(abiFn()) + ", host=" + std::to_string(PROXYPLUS_PLUGIN_ABI_VERSION) + ")"); ::dlclose(handle); Loading @@ -60,6 +63,7 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st IPlugin *instance = createFn(); if (!instance) { std::cerr << "[plugin] " << fname << ": proxyplus_plugin_create returned null" << std::endl; _errors.push_back(fname + ": proxyplus_plugin_create returned null"); ::dlclose(handle); continue; Loading @@ -67,6 +71,7 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st auto configIt = configByName.find(instance->name()); instance->init(_authFacade, configIt != configByName.end() ? configIt->second : ""); _plugins.push_back({handle, instance, destroyFn}); std::cout << "[plugin] loaded " << instance->name() << std::endl; } ::closedir(d); } Loading Loading
src/plugin/PluginManager.cpp +7 −2 Changes for src/plugin/PluginManager.cpp: 7 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -26,16 +26,16 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st struct dirent *entry; while ((entry = ::readdir(d)) != nullptr) { std::string fname = entry->d_name; std::cout << "[plugin] checking " << fname << std::endl; if (fname.size() < 3 || fname.substr(fname.size() - 3) != ".so") continue; std::string path = dir + "/" + fname; std::cout << "[plugin] loading " << path << std::endl; void *handle = ::dlopen(path.c_str(), RTLD_NOW | RTLD_LOCAL); if (!handle) { std::cerr << "[plugin] " << fname << ": dlopen failed: " << (::dlerror() ? ::dlerror() : "unknown error") << std::endl; _errors.push_back(fname + ": " + std::string(::dlerror() ? ::dlerror() : "dlopen failed")); continue; } Loading @@ -47,11 +47,14 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st reinterpret_cast<void (*)(IPlugin *)>(::dlsym(handle, "proxyplus_plugin_destroy")); if (!abiFn || !createFn || !destroyFn) { std::cerr << "[plugin] " << fname << ": missing required plugin ABI symbols" << std::endl; _errors.push_back(fname + ": missing required plugin ABI symbols"); ::dlclose(handle); continue; } if (abiFn() != PROXYPLUS_PLUGIN_ABI_VERSION) { std::cerr << "[plugin] " << fname << ": ABI version mismatch (plugin=" << abiFn() << ", host=" << PROXYPLUS_PLUGIN_ABI_VERSION << ")" << std::endl; _errors.push_back(fname + ": ABI version mismatch (plugin=" + std::to_string(abiFn()) + ", host=" + std::to_string(PROXYPLUS_PLUGIN_ABI_VERSION) + ")"); ::dlclose(handle); Loading @@ -60,6 +63,7 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st IPlugin *instance = createFn(); if (!instance) { std::cerr << "[plugin] " << fname << ": proxyplus_plugin_create returned null" << std::endl; _errors.push_back(fname + ": proxyplus_plugin_create returned null"); ::dlclose(handle); continue; Loading @@ -67,6 +71,7 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st auto configIt = configByName.find(instance->name()); instance->init(_authFacade, configIt != configByName.end() ? configIt->second : ""); _plugins.push_back({handle, instance, destroyFn}); std::cout << "[plugin] loaded " << instance->name() << std::endl; } ::closedir(d); } Loading