From 3ef3047681f0813d8f1d06939eaa2ef378d99505 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 3 Nov 2015 13:08:21 +0100 Subject: Add UserManager::NextAlreadySentId() and convert all code to use it --- src/usermanager.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/usermanager.cpp') diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 41061f6d1..c593e149f 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -368,3 +368,8 @@ void UserManager::DoBackgroundUserStuff() } } } + +already_sent_t UserManager::NextAlreadySentId() +{ + return ++LocalUser::already_sent_id; +} -- cgit v1.2.3 From c89cc290fbc6d53040fc8abc6fc0b0cb637beee9 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 3 Nov 2015 13:13:00 +0100 Subject: Move already sent id rollover handling and static LocalUser::already_sent_id into UserManager --- include/usermanager.h | 5 +++++ include/users.h | 1 - src/usermanager.cpp | 16 +++++++++++++--- src/users.cpp | 2 -- 4 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src/usermanager.cpp') diff --git a/include/usermanager.h b/include/usermanager.h index 605b841bb..670e51dd5 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -56,6 +56,11 @@ class CoreExport UserManager : public fakederef */ LocalList local_users; + /** Last used already sent id, used when sending messages to neighbors to help determine whether the message has + * been sent to a particular user or not. See User::ForEachNeighbor() for more info. + */ + already_sent_t already_sent_id; + public: /** Constructor, initializes variables */ diff --git a/include/users.h b/include/users.h index 03540018b..fa346a329 100644 --- a/include/users.h +++ b/include/users.h @@ -720,7 +720,6 @@ class CoreExport LocalUser : public User, public insp::intrusive_list_nodealready_sent = 0; + } + } + return already_sent_id; } diff --git a/src/users.cpp b/src/users.cpp index 258544312..93fd8d065 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -26,8 +26,6 @@ #include "inspircd.h" #include "xline.h" -already_sent_t LocalUser::already_sent_id = 0; - bool User::IsNoticeMaskSet(unsigned char sm) { if (!isalpha(sm)) -- cgit v1.2.3 From aa05a6fd4d5c11dc8e8adc469134a2802446fe9f Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 3 Nov 2015 13:16:19 +0100 Subject: Remove UserManager::GarbageCollect() --- include/usermanager.h | 5 ----- src/inspircd.cpp | 3 --- src/usermanager.cpp | 7 ------- 3 files changed, 15 deletions(-) (limited to 'src/usermanager.cpp') diff --git a/include/usermanager.h b/include/usermanager.h index 670e51dd5..941569e8c 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -88,11 +88,6 @@ class CoreExport UserManager : public fakederef */ unsigned int unregistered_count; - /** - * Reset the already_sent IDs so we don't wrap it around and drop a message - */ - void GarbageCollect(); - /** Perform background user events such as PING checks */ void DoBackgroundUserStuff(); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index fce99f421..145d4582a 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -664,10 +664,7 @@ void InspIRCd::Run() OLDTIME = TIME.tv_sec; if ((TIME.tv_sec % 3600) == 0) - { - Users->GarbageCollect(); FOREACH_MOD(OnGarbageCollect, ()); - } Timers.TickTimers(TIME.tv_sec); Users->DoBackgroundUserStuff(); diff --git a/src/usermanager.cpp b/src/usermanager.cpp index d81b83d20..ba6bbf36b 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -279,13 +279,6 @@ void UserManager::ServerNoticeAll(const char* text, ...) } } -void UserManager::GarbageCollect() -{ - // Reset the already_sent IDs so we don't wrap it around and drop a message - for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i) - (**i).already_sent = 0; -} - /* this returns true when all modules are satisfied that the user should be allowed onto the irc server * (until this returns true, a user will block in the waiting state, waiting to connect up to the * registration timeout maximum seconds) -- cgit v1.2.3