server: skip the O(users) callerid ACCEPT scrub on quit unless the departing nick is actually accepted by someone — a reverse count (accepted_nicks) maintained through centralized accept_add/accept_remove helpers avoids scanning every user's accept list on each quit (O(users*quits) on a netsplit); the full scrub still runs when the count is nonzero, so the nick-reuse protection is unchanged
This commit is contained in:
parent
ab0ccae71f
commit
fb1a9f3d70
3 changed files with 63 additions and 10 deletions
|
|
@ -637,10 +637,13 @@ pub(crate) fn deliver(s: &mut Server, uid: Uid, params: &[String], notice: bool)
|
|||
.map(|u| u.nick.to_ascii_lowercase())
|
||||
.unwrap_or_default();
|
||||
let maxacc = s.conf_num("maxaccept", crate::watch::ACCEPT_MAX);
|
||||
if let Some(su) = s.users.get_mut(&uid) {
|
||||
if !tnick.is_empty() && su.accept.len() < maxacc && !su.accept.contains(&tnick) {
|
||||
su.accept.push(tnick);
|
||||
}
|
||||
let can_add = s
|
||||
.users
|
||||
.get(&uid)
|
||||
.map(|u| !tnick.is_empty() && u.accept.len() < maxacc && !u.accept.contains(&tnick))
|
||||
.unwrap_or(false);
|
||||
if can_add {
|
||||
s.accept_add(uid, tnick);
|
||||
}
|
||||
}
|
||||
} else if let Some((uuid, via)) = s.find_remote(target) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue