X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/3a45cd9275dc9279e133deb0932402ae5f4d0b5f..746862797a13228a4c41bc83500cdff2751db5c2:/projects/stargazer/plugins/authorization/stress/stress.cpp diff --git a/projects/stargazer/plugins/authorization/stress/stress.cpp b/projects/stargazer/plugins/authorization/stress/stress.cpp index 481444b5..6473b57e 100644 --- a/projects/stargazer/plugins/authorization/stress/stress.cpp +++ b/projects/stargazer/plugins/authorization/stress/stress.cpp @@ -33,35 +33,14 @@ #include "stg/user.h" #include "stg/common.h" #include "stg/user_property.h" +#include "stg/plugin_creator.h" #include "stress.h" -class STRESS_CREATOR -{ -private: - AUTH_STRESS * dc; - -public: - STRESS_CREATOR() - { - printfd(__FILE__, "constructor STRESS_CREATOR\n"); - dc = new AUTH_STRESS(); - }; - ~STRESS_CREATOR() - { - printfd(__FILE__, "destructor STRESS_CREATOR\n"); - delete dc; - }; - - PLUGIN * GetPlugin() - { - return dc; - }; -}; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -STRESS_CREATOR stressc; +PLUGIN_CREATOR stressc; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -179,7 +158,7 @@ users_iter = usersList.begin(); while (users_iter != usersList.end()) { Authorize(*users_iter); - users_iter++; + ++users_iter; } //isRunning = true; @@ -197,7 +176,8 @@ if (isRunning) { if (!isRunning) break; - usleep(200000); + struct timespec ts = {0, 200000000}; + nanosleep(&ts, NULL); } //after 5 seconds waiting thread still running. now killing it @@ -225,12 +205,12 @@ return isRunning; //----------------------------------------------------------------------------- uint16_t AUTH_STRESS::GetStartPosition() const { -return 70; +return 30; } //----------------------------------------------------------------------------- uint16_t AUTH_STRESS::GetStopPosition() const { -return 70; +return 30; } //----------------------------------------------------------------------------- void AUTH_STRESS::SetUserNotifiers(USER_PTR u) @@ -351,7 +331,7 @@ while (users_iter != usersList.end()) printfd(__FILE__, "User removed from list %s\n", u->GetLogin().c_str()); break; } - users_iter++; + ++users_iter; } } //----------------------------------------------------------------------------- @@ -363,8 +343,7 @@ return -1; //----------------------------------------------------------------------------- void * AUTH_STRESS::Run(void * d) { -AUTH_STRESS * ia; -ia = (AUTH_STRESS *)d; +AUTH_STRESS * ia = static_cast(d); ia->isRunning = true; @@ -387,7 +366,7 @@ while (ia->nonstop) printfd(__FILE__, "AUTH_STRESS::Unauthorize - user: '%s'\n", (*users_iter)->GetLogin().c_str()); } - users_iter++; + ++users_iter; } sleep(1);