Commit c1bb0dfd authored by jan.koester's avatar jan.koester
Browse files

test

parent 52d7b696
Loading
Loading
Loading
Loading
+0 −10
Changes for src/plugin/PluginManager.cpp: 0 added lines, 10 removed lines.
Original line number Diff line number Diff line
#include <iostream>

#include "PluginManager.h"

#include <dlfcn.h>
@@ -30,8 +28,6 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st

        std::string path = dir + "/" + fname;

        std::cout << "[plugin] loading " << path << std::endl;

        // RTLD_GLOBAL, not RTLD_LOCAL: IPlugin and its extension-point interfaces (see
        // PluginApi.h) have no out-of-line virtual function, so their vtable/typeinfo get
        // vague (weak) linkage rather than one strong definition. Under RTLD_LOCAL every
@@ -44,7 +40,6 @@ void PluginManager::loadDirectory(const std::string &dir, const std::map<std::st
        void *handle = ::dlopen(path.c_str(), RTLD_NOW | RTLD_GLOBAL);

        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;
        }
@@ -56,14 +51,11 @@ 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);
@@ -72,7 +64,6 @@ 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;
@@ -80,7 +71,6 @@ 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);
}