X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/2db10cd7443b651fc3d116fd007db85347de7acb..203056055696ed765a66342e7e9e74ba1ffc10a3:/projects/stargazer/users_impl.cpp diff --git a/projects/stargazer/users_impl.cpp b/projects/stargazer/users_impl.cpp index c139e65c..08181ae1 100644 --- a/projects/stargazer/users_impl.cpp +++ b/projects/stargazer/users_impl.cpp @@ -71,7 +71,9 @@ USERS_IMPL::USERS_IMPL(SETTINGS_IMPL * s, STORE * st, TARIFFS * t, const ADMIN * handle(0), searchDescriptors(), onAddNotifiers(), - onDelNotifiers() + onDelNotifiers(), + onAddNotifiersImpl(), + onDelNotifiersImpl() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); @@ -179,12 +181,24 @@ users.push_front(u); AddUserIntoIndexes(users.begin()); SetUserNotifiers(users.begin()); -// õ×ÅÄÏÍÌÑÅÍ ×ÓÅÈ ÖÅÌÁÀÝÉÈ, ÞÔÏ ÄÏÂÁ×ÌÅÎ ÎÏ×ÙÊ ÐÏÌØÚÏ×ÁÔÅÌØ -set *>::iterator ni = onAddNotifiers.begin(); -while (ni != onAddNotifiers.end()) { - (*ni)->Notify(&users.front()); - ++ni; + // Fire all "on add" notifiers + set *>::iterator ni = onAddNotifiers.begin(); + while (ni != onAddNotifiers.end()) + { + (*ni)->Notify(&users.front()); + ++ni; + } + } + + { + // Fire all "on add" implementation notifiers + set *>::iterator ni = onAddNotifiersImpl.begin(); + while (ni != onAddNotifiersImpl.end()) + { + (*ni)->Notify(&users.front()); + ++ni; + } } return 0; @@ -215,11 +229,22 @@ if (!priv->userAddDel) } } -set *>::iterator ni = onDelNotifiers.begin(); -while (ni != onDelNotifiers.end()) { - (*ni)->Notify(&(*u)); - ++ni; + set *>::iterator ni = onDelNotifiers.begin(); + while (ni != onDelNotifiers.end()) + { + (*ni)->Notify(&(*u)); + ++ni; + } + } + + { + set *>::iterator ni = onDelNotifiersImpl.begin(); + while (ni != onDelNotifiersImpl.end()) + { + (*ni)->Notify(&(*u)); + ++ni; + } } { @@ -578,6 +603,15 @@ ipIndex.erase(it); } //----------------------------------------------------------------------------- int USERS_IMPL::FindByIPIdx(uint32_t ip, USER_PTR * usr) const +{ + USER_IMPL * ptr = NULL; + if (FindByIPIdx(ip, &ptr)) + return -1; + *usr = ptr; + return 0; +} +//----------------------------------------------------------------------------- +int USERS_IMPL::FindByIPIdx(uint32_t ip, USER_IMPL ** usr) const { STG_LOCKER lock(&mutex, __FILE__, __LINE__); @@ -613,7 +647,6 @@ onAddNotifiers.insert(n); void USERS_IMPL::DelNotifierUserAdd(NOTIFIER_BASE * n) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); -//printfd(__FILE__, "DelNotifierUserAdd\n"); onAddNotifiers.erase(n); } //----------------------------------------------------------------------------- @@ -629,6 +662,30 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); onDelNotifiers.erase(n); } //----------------------------------------------------------------------------- +void USERS_IMPL::AddNotifierUserAdd(NOTIFIER_BASE * n) +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +onAddNotifiersImpl.insert(n); +} +//----------------------------------------------------------------------------- +void USERS_IMPL::DelNotifierUserAdd(NOTIFIER_BASE * n) +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +onAddNotifiersImpl.erase(n); +} +//----------------------------------------------------------------------------- +void USERS_IMPL::AddNotifierUserDel(NOTIFIER_BASE * n) +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +onDelNotifiersImpl.insert(n); +} +//----------------------------------------------------------------------------- +void USERS_IMPL::DelNotifierUserDel(NOTIFIER_BASE * n) +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +onDelNotifiersImpl.erase(n); +} +//----------------------------------------------------------------------------- int USERS_IMPL::OpenSearch() { STG_LOCKER lock(&mutex, __FILE__, __LINE__); @@ -638,6 +695,15 @@ return handle; } //----------------------------------------------------------------------------- int USERS_IMPL::SearchNext(int h, USER_PTR * user) +{ + USER_IMPL * ptr = NULL; + if (SearchNext(h, &ptr)) + return -1; + *user = ptr; + return 0; +} +//----------------------------------------------------------------------------- +int USERS_IMPL::SearchNext(int h, USER_IMPL ** user) { STG_LOCKER lock(&mutex, __FILE__, __LINE__);