Commit 4d8d6f51 authored by Jan Koester's avatar Jan Koester
Browse files

test

parent 73650abf
Loading
Loading
Loading
Loading
Loading
+1 −0
Changes for plugin/ad/ad.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -267,6 +267,7 @@ namespace fenrirds {
        const char *name() const override { return "ad"; }
        void init() override;
        void run() override;
        void stop() override { _Running = false; }

        /* AdPlugin interface */
        std::string baseDN(const std::string &domain) const override;
+1 −0
Changes for plugin/dns/dns.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ namespace fenrirds {
        const char *name() const override { return "dns"; }
        void init() override;    /* bind sockets (while root) */
        void run() override;     /* serve (blocking) */
        void stop() override { _Running = false; }

    private:
        /* DNS resource record kinds we answer */
+3 −1
Changes for plugin/krb5/krb5.h: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <mutex>
#include <memory>
#include <thread>
#include <atomic>

#include <uuidp.h>
#include <netplus/socket.h>
@@ -725,6 +726,7 @@ namespace fenrirds {
        const char *name() const override { return "krb5"; }
        void init() override;
        void run() override { runKdc(0); }
        void stop() override { _Running = false; }

        /* KdcPlugin interface */
        std::vector<uint8_t> string2key(const std::string &password,
@@ -821,7 +823,7 @@ namespace fenrirds {
         * Windows sends AS-REQ over UDP first. Served in its own thread. */
        netplus::udp                     *_Udp = nullptr;
        std::thread                       _UdpThread;
        bool                              _Running = false;
        std::atomic<bool>                 _Running{false};
        void                              udpLoop();
    };

+10 −1
Changes for src/fenrirds.cpp: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@

#include <json-c/json.h>
#include <netplus/exception.h>
#include <netplus/eventapi.h>

#ifndef _WIN32
#include <unistd.h>
@@ -1222,7 +1223,6 @@ int main(int argc,char *argv[]){
                    std::cerr << "Plugin '" << pname << "' unknown error" << std::endl;
                }
            });
            pluginThreads.back().detach();
        }

        /* Periodic auto-vacuum thread — compacts file backends to prevent
@@ -1265,6 +1265,15 @@ int main(int argc,char *argv[]){

        fenrirds.runEventloop();

        /* Stop the plugins and wait for their threads before pluginMgr
         * destroys the instances and unloads the libraries: a thread still
         * in run() would use freed objects or unmapped code */
        netplus::event::requestStop();
        pluginMgr.stopAll();
        for (auto &t : pluginThreads)
            if (t.joinable())
                t.join();

        /* Stop auto-vacuum */
        vacuumRunning = false;
        vacuumCv.notify_all();
+18 −0
Changes for src/plugin.cpp: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -90,9 +90,14 @@ static std::string pluginError() {
#endif

PluginManager::~PluginManager() {
    /* destroy every instance before unloading any library: plugins hold
     * objects and pointers of each other (g_AdPlugin, g_KdcPlugin) */
    for (auto &[name, lp] : _Plugins) {
        if (lp.instance && lp.destroy)
            lp.destroy(lp.instance);
        lp.instance = nullptr;
    }
    for (auto &[name, lp] : _Plugins) {
        if (lp.handle)
            pluginClose(lp.handle);
    }
@@ -215,4 +220,17 @@ void PluginManager::initAll() {
    }
}

void PluginManager::stopAll() {
    for (auto &[name, lp] : _Plugins) {
        if (lp.instance && lp.ready) {
            try {
                lp.instance->stop();
            } catch (const std::exception &e) {
                std::cerr << "Plugin stop failed: " << name << ": "
                          << e.what() << std::endl;
            }
        }
    }
}

} /* namespace fenrirds */
Loading