diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-11-03 13:13:00 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-11-03 13:13:00 +0100 |
commit | c89cc290fbc6d53040fc8abc6fc0b0cb637beee9 (patch) | |
tree | 97060938b9341f81ad2fb47a9afecd720d182569 | |
parent | 3ef3047681f0813d8f1d06939eaa2ef378d99505 (diff) |
Move already sent id rollover handling and static LocalUser::already_sent_id into UserManager
-rw-r--r-- | include/usermanager.h | 5 | ||||
-rw-r--r-- | include/users.h | 1 | ||||
-rw-r--r-- | src/usermanager.cpp | 16 | ||||
-rw-r--r-- | src/users.cpp | 2 |
4 files changed, 18 insertions, 6 deletions
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<UserManager> */ 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_node<Local */ unsigned int CommandFloodPenalty; - static already_sent_t already_sent_id; already_sent_t already_sent; /** Check if the user matches a G or K line, and disconnect them if they do. diff --git a/src/usermanager.cpp b/src/usermanager.cpp index c593e149f..d81b83d20 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -49,7 +49,8 @@ namespace } UserManager::UserManager() - : unregistered_count(0) + : already_sent_id(0) + , unregistered_count(0) { } @@ -281,7 +282,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 - LocalUser::already_sent_id = 0; for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i) (**i).already_sent = 0; } @@ -371,5 +371,15 @@ void UserManager::DoBackgroundUserStuff() already_sent_t UserManager::NextAlreadySentId() { - return ++LocalUser::already_sent_id; + if (++already_sent_id == 0) + { + // Wrapped around, reset the already_sent ids of all users + already_sent_id = 1; + for (LocalList::iterator i = local_users.begin(); i != local_users.end(); ++i) + { + LocalUser* user = *i; + user->already_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)) |