X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/4f1aca7dfb6adf867713ad48e14ad79080e13cfa..c8b080defffe28f5fc1aa39447a467d8f7b7ee5c:/projects/stargazer/users_impl.cpp?ds=sidebyside diff --git a/projects/stargazer/users_impl.cpp b/projects/stargazer/users_impl.cpp index dfdc8634..5b88e685 100644 --- a/projects/stargazer/users_impl.cpp +++ b/projects/stargazer/users_impl.cpp @@ -88,23 +88,39 @@ pthread_mutex_destroy(&mutex); //----------------------------------------------------------------------------- int USERS_IMPL::FindByNameNonLock(const std::string & login, user_iter * user) { -std::map::iterator iter; -iter = loginIndex.find(login); -if (iter != loginIndex.end()) - { - if (user) - *user = iter->second; - return 0; - } -return -1; +const std::map::const_iterator iter(loginIndex.find(login)); +if (iter == loginIndex.end()) + return -1; +if (user) + *user = iter->second; +return 0; +} +//----------------------------------------------------------------------------- +int USERS_IMPL::FindByNameNonLock(const std::string & login, const_user_iter * user) const +{ +const std::map::const_iterator iter(loginIndex.find(login)); +if (iter == loginIndex.end()) + return -1; +if (user) + *user = iter->second; +return 0; } //----------------------------------------------------------------------------- int USERS_IMPL::FindByName(const std::string & login, USER_PTR * user) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); user_iter u; -int res = FindByNameNonLock(login, &u); -if (res) +if (FindByNameNonLock(login, &u)) + return -1; +*user = &(*u); +return 0; +} +//----------------------------------------------------------------------------- +int USERS_IMPL::FindByName(const std::string & login, CONST_USER_PTR * user) const +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +const_user_iter u; +if (FindByNameNonLock(login, &u)) return -1; *user = &(*u); return 0; @@ -702,7 +718,9 @@ std::list::const_iterator iter; iter = users.begin(); while (iter != users.end()) { - if (iter->GetLogin() != login && iter->GetProperty().ips.Get().IsIPInIPS(ip)) + if (iter->GetLogin() != login && + !iter->GetProperty().ips.Get().IsAnyIP() && + iter->GetProperty().ips.Get().IsIPInIPS(ip)) { if (user != NULL) *user = &(*iter);