Commit 1cff0dbd authored by Jan Koester's avatar Jan Koester
Browse files

test

parent 4d8d6f51
Loading
Loading
Loading
Loading
Loading
+19 −8
Changes for src/fenrirds.cpp: 19 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -1225,6 +1225,24 @@ int main(int argc,char *argv[]){
            });
        }

        /* 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. Also runs when
         * an exception unwinds this scope (a joinable std::thread would
         * otherwise terminate the process). */
        struct PluginShutdown {
            fenrirds::PluginManager &mgr;
            std::vector<std::thread> &threads;
            void operator()() {
                netplus::event::requestStop();
                mgr.stopAll();
                for (auto &t : threads)
                    if (t.joinable())
                        t.join();
            }
            ~PluginShutdown() { (*this)(); }
        } stopPlugins{pluginMgr, pluginThreads};

        /* Periodic auto-vacuum thread — compacts file backends to prevent
           bloat from deleted/overwritten records which causes slow I/O and
           timeouts over time.  Interval is configurable via config (hours),
@@ -1265,14 +1283,7 @@ 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();
        stopPlugins();

        /* Stop auto-vacuum */
        vacuumRunning = false;