diff --git a/irc/client.go b/irc/client.go index c31bdd28..add5b3d4 100644 --- a/irc/client.go +++ b/irc/client.go @@ -987,6 +987,7 @@ func (client *Client) destroy(session *Session) { // if it's our job to destroy it, don't let anyone else try client.destroyed = true } + exitedSnomaskSent := client.exitedSnomaskSent client.stateMutex.Unlock() // destroy all applicable sessions: @@ -1101,7 +1102,7 @@ func (client *Client) destroy(session *Session) { friend.sendFromClientInternal(false, splitQuitMessage.Time, splitQuitMessage.Msgid, details.nickMask, details.accountName, nil, "QUIT", quitMessage) } - if !client.exitedSnomaskSent && registered { + if !exitedSnomaskSent && registered { client.server.snomasks.Send(sno.LocalQuits, fmt.Sprintf(ircfmt.Unescape("%s$r exited the network"), details.nick)) } } diff --git a/irc/getters.go b/irc/getters.go index 4d3ad7a8..91187cc1 100644 --- a/irc/getters.go +++ b/irc/getters.go @@ -187,6 +187,12 @@ func (client *Client) SetAway(away bool, awayMessage string) (changed bool) { return } +func (client *Client) SetExitedSnomaskSent() { + client.stateMutex.Lock() + client.exitedSnomaskSent = true + client.stateMutex.Unlock() +} + // uniqueIdentifiers returns the strings for which the server enforces per-client // uniqueness/ownership; no two clients can have colliding casefolded nicks or // skeletons. diff --git a/irc/handlers.go b/irc/handlers.go index a80c366a..e6cf61ce 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -1052,7 +1052,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res } for _, mcl := range clientsToKill { - mcl.exitedSnomaskSent = true + mcl.SetExitedSnomaskSent() mcl.Quit(fmt.Sprintf(mcl.t("You have been banned from this server (%s)"), reason), nil) if mcl == client { killClient = true @@ -1362,7 +1362,7 @@ func killHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp quitMsg := fmt.Sprintf("Killed (%s (%s))", client.nick, comment) server.snomasks.Send(sno.LocalKills, fmt.Sprintf(ircfmt.Unescape("%s$r was killed by %s $c[grey][$r%s$c[grey]]"), target.nick, client.nick, comment)) - target.exitedSnomaskSent = true + target.SetExitedSnomaskSent() target.Quit(quitMsg, nil) target.destroy(nil) @@ -1489,7 +1489,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res } for _, mcl := range clientsToKill { - mcl.exitedSnomaskSent = true + mcl.SetExitedSnomaskSent() mcl.Quit(fmt.Sprintf(mcl.t("You have been banned from this server (%s)"), reason), nil) if mcl == client { killClient = true