X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/22cb2560274e05e6490cf964cbbeb74a1991c642..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 020c1365..5c176f45 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp @@ -27,7 +27,9 @@ #include "parser_admins.h" #include "parser_tariffs.h" #include "parser_users.h" +#include "parser_services.h" #include "parser_message.h" +#include "parser_user_info.h" #include "parser_auth_by.h" #include "stg/common.h" @@ -48,15 +50,16 @@ namespace SP = STG::PARSER; -CONFIGPROTO::CONFIGPROTO(PLUGIN_LOGGER & l) +CONFIGPROTO::CONFIGPROTO(STG::PluginLogger & l) : m_settings(NULL), m_admins(NULL), m_tariffs(NULL), m_users(NULL), + m_services(NULL), + m_corporations(NULL), m_store(NULL), m_port(0), m_bindAddress("0.0.0.0"), - m_running(false), m_stopped(true), m_logger(l), m_listenSocket(-1) @@ -86,7 +89,6 @@ int CONFIGPROTO::Prepare() sigaddset(&sigmask, SIGUSR1); sigaddset(&sigmask, SIGHUP); pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask); - m_listenSocket = socket(PF_INET, SOCK_STREAM, 0); if (m_listenSocket < 0) @@ -117,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}; @@ -143,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; @@ -163,7 +163,7 @@ void CONFIGPROTO::Run() m_logger(m_errorStr); break; } - if (!m_running) + if (token.stop_requested()) break; if (res > 0) HandleEvents(fds); @@ -214,6 +214,8 @@ void CONFIGPROTO::RegisterParsers() assert(m_admins != NULL); assert(m_users != NULL); assert(m_tariffs != NULL); + assert(m_services != NULL); + assert(m_corporations != NULL); SP::GET_SERVER_INFO::FACTORY::Register(m_registry, *m_settings, *m_users, *m_tariffs); @@ -234,9 +236,17 @@ void CONFIGPROTO::RegisterParsers() SP::CHG_USER::FACTORY::Register(m_registry, *m_users, *m_store, *m_tariffs); SP::CHECK_USER::FACTORY::Register(m_registry, *m_users); + SP::GET_SERVICES::FACTORY::Register(m_registry, *m_services); + SP::GET_SERVICE::FACTORY::Register(m_registry, *m_services); + SP::ADD_SERVICE::FACTORY::Register(m_registry, *m_services); + SP::DEL_SERVICE::FACTORY::Register(m_registry, *m_services); + SP::CHG_SERVICE::FACTORY::Register(m_registry, *m_services); + SP::SEND_MESSAGE::FACTORY::Register(m_registry, *m_users); SP::AUTH_BY::FACTORY::Register(m_registry, *m_users); + + SP::USER_INFO::FACTORY::Register(m_registry, *m_users); } int CONFIGPROTO::MaxFD() const