X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/d1c864e3feaf4295d366e2ef497495738ce15337..a500fb72810060e52d87ad2c2e4691531f0bcc5a:/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp?ds=sidebyside diff --git a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp index f5a57a48..5c176f45 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp @@ -50,7 +50,7 @@ namespace SP = STG::PARSER; -CONFIGPROTO::CONFIGPROTO(PLUGIN_LOGGER & l) +CONFIGPROTO::CONFIGPROTO(STG::PluginLogger & l) : m_settings(NULL), m_admins(NULL), m_tariffs(NULL), @@ -60,7 +60,6 @@ CONFIGPROTO::CONFIGPROTO(PLUGIN_LOGGER & l) m_store(NULL), m_port(0), m_bindAddress("0.0.0.0"), - m_running(false), m_stopped(true), m_logger(l), m_listenSocket(-1) @@ -69,9 +68,16 @@ CONFIGPROTO::CONFIGPROTO(PLUGIN_LOGGER & l) CONFIGPROTO::~CONFIGPROTO() { + { std::deque::iterator it; for (it = m_conns.begin(); it != m_conns.end(); ++it) delete *it; + } + { + BASE_PARSER::REGISTRY::iterator it; + for (it = m_registry.begin(); it != m_registry.end(); ++it) + delete it->second; + } } int CONFIGPROTO::Prepare() @@ -113,14 +119,12 @@ int CONFIGPROTO::Prepare() RegisterParsers(); - m_running = true; m_stopped = false; return 0; } int CONFIGPROTO::Stop() { - m_running = false; for (int i = 0; i < 5 && !m_stopped; ++i) { struct timespec ts = {0, 200000000}; @@ -139,9 +143,9 @@ int CONFIGPROTO::Stop() return 0; } -void CONFIGPROTO::Run() +void CONFIGPROTO::Run(std::stop_token token) { - while (m_running) + while (!token.stop_requested()) { fd_set fds; @@ -159,7 +163,7 @@ void CONFIGPROTO::Run() m_logger(m_errorStr); break; } - if (!m_running) + if (token.stop_requested()) break; if (res > 0) HandleEvents(fds);