server: scrub a departed user's pending invites via a User.invited reverse index instead of scanning every channel on the network per quit — the old O(channels)-per-quit path was O(channels*quits) on a netsplit; the index is maintained at the 4 invite add/remove sites (INVITE cmd, S2S INVITE, join-consume, UNINVITE)
This commit is contained in:
parent
5101b1361d
commit
ab0ccae71f
7 changed files with 23 additions and 2 deletions
|
|
@ -323,6 +323,9 @@ impl Command for Invite {
|
|||
if let Some(ch) = s.channels.get_mut(&key) {
|
||||
ch.invites.insert(tuid);
|
||||
}
|
||||
if let Some(u) = s.users.get_mut(&tuid) {
|
||||
u.invited.insert(key.clone()); // reverse index for O(1) quit scrub
|
||||
}
|
||||
let who = s.users[&tuid].nick.clone();
|
||||
s.numeric(uid, RPL_INVITING, &format!("{who} {chan}"));
|
||||
let prefix = s.users[&uid].prefix();
|
||||
|
|
@ -390,6 +393,9 @@ impl Command for Uninvite {
|
|||
.get_mut(&key)
|
||||
.map(|ch| ch.invites.remove(&tuid))
|
||||
.unwrap_or(false);
|
||||
if let Some(u) = s.users.get_mut(&tuid) {
|
||||
u.invited.remove(&key); // keep the reverse index in sync
|
||||
}
|
||||
let who = s.users[&tuid].nick.clone();
|
||||
let word = if removed {
|
||||
"is no longer invited to"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue