From: Maxim Mamontov Date: Sun, 20 Dec 2015 20:05:06 +0000 (+0200) Subject: Merge branch 'stg-2.409' into stg-2.409-radius X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/65eef741908a8005f8a1e11f1fa0f6c19afd3d0c?hp=a637d472ffa2023dd0748557f9ef343d7138c2f0 Merge branch 'stg-2.409' into stg-2.409-radius --- diff --git a/projects/stargazer/main.cpp b/projects/stargazer/main.cpp index 73786c4e..3c216977 100644 --- a/projects/stargazer/main.cpp +++ b/projects/stargazer/main.cpp @@ -363,6 +363,8 @@ while (running) WriteServLog("+++++++++++++++++++++++++++++++++++++++++++++"); +manager.stop(); + if (loop.Stop()) WriteServLog("Event loop not stopped."); diff --git a/projects/stargazer/plugin_mgr.cpp b/projects/stargazer/plugin_mgr.cpp index 5346db8b..b87ab277 100644 --- a/projects/stargazer/plugin_mgr.cpp +++ b/projects/stargazer/plugin_mgr.cpp @@ -97,23 +97,7 @@ PluginManager::PluginManager(const SETTINGS_IMPL& settings, PluginManager::~PluginManager() { - std::sort(m_modules.begin(), m_modules.end(), StopModCmp); - for (size_t i = 0; i < m_modules.size(); ++i) - { - PLUGIN & plugin = m_modules[i]->GetPlugin(); - if (m_modules[i]->Stop()) - { - m_log("Failed to stop module '%s': '%s'", plugin.GetVersion().c_str(), - plugin.GetStrError().c_str()); - printfd(__FILE__, "Failed to stop module '%s': '%s'\n", plugin.GetVersion().c_str(), - plugin.GetStrError().c_str()); - } - else - { - m_log("Module '%s' stopped successfully.", plugin.GetVersion().c_str()); - printfd(__FILE__, "Module '%s' stopped successfully.\n", plugin.GetVersion().c_str()); - } - } + stop(); for (size_t i = 0; i < m_modules.size(); ++i) delete m_modules[i]; } @@ -132,3 +116,26 @@ void PluginManager::reload() } } } + +void PluginManager::stop() +{ + std::sort(m_modules.begin(), m_modules.end(), StopModCmp); + for (size_t i = 0; i < m_modules.size(); ++i) + { + if (!m_modules[i]->IsRunning()) + continue; + PLUGIN & plugin = m_modules[i]->GetPlugin(); + if (m_modules[i]->Stop()) + { + m_log("Failed to stop module '%s': '%s'", plugin.GetVersion().c_str(), + plugin.GetStrError().c_str()); + printfd(__FILE__, "Failed to stop module '%s': '%s'\n", plugin.GetVersion().c_str(), + plugin.GetStrError().c_str()); + } + else + { + m_log("Module '%s' stopped successfully.", plugin.GetVersion().c_str()); + printfd(__FILE__, "Module '%s' stopped successfully.\n", plugin.GetVersion().c_str()); + } + } +} diff --git a/projects/stargazer/plugin_mgr.h b/projects/stargazer/plugin_mgr.h index 79b6cae9..c9ec8dff 100644 --- a/projects/stargazer/plugin_mgr.h +++ b/projects/stargazer/plugin_mgr.h @@ -49,6 +49,7 @@ class PluginManager ~PluginManager(); void reload(); + void stop(); private: std::vector m_modules; diff --git a/projects/stargazer/users_impl.cpp b/projects/stargazer/users_impl.cpp index 97873aeb..18d1abaf 100644 --- a/projects/stargazer/users_impl.cpp +++ b/projects/stargazer/users_impl.cpp @@ -319,6 +319,7 @@ STG_LOCKER lock(&mutex); if (FindByNameNonLock(login, &iter)) { WriteServLog("Attempt to unauthorize non-existant user '%s'", login.c_str()); + printfd(__FILE__, "Attempt to unauthorize non-existant user '%s'", login.c_str()); return false; } @@ -424,15 +425,7 @@ while (us->nonstop) stgUsleep(100000); } //while (us->nonstop) -user_iter ui = us->users.begin(); -while (ui != us->users.end()) - { - us->DelUserFromIndexes(ui); - ++ui; - } - -std::list::iterator iter; -iter = us->usersToDelete.begin(); +std::list::iterator iter(us->usersToDelete.begin()); while (iter != us->usersToDelete.end()) { iter->delTime -= 2 * userDeleteDelayTime;