3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 07:29:31 +01:00

Merge pull request #849 from slingamn/issue848_lusers_again.1

fix #848
This commit is contained in:
Shivaram Lingamneni 2020-03-06 02:08:19 -08:00 committed by GitHub
commit b68b28e189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -1185,9 +1185,11 @@ func (client *Client) destroy(session *Session) {
// should we destroy the whole client this time? // should we destroy the whole client this time?
// BRB is not respected if this is a destroy of the whole client (i.e., session == nil) // BRB is not respected if this is a destroy of the whole client (i.e., session == nil)
brbEligible := session != nil && (brbState == BrbEnabled || alwaysOn) brbEligible := session != nil && brbState == BrbEnabled
alreadyDestroyed := client.destroyed shouldDestroy := !client.destroyed && remainingSessions == 0 && !brbEligible && !alwaysOn
shouldDestroy := !alreadyDestroyed && remainingSessions == 0 && !brbEligible // decrement stats on a true destroy, or for the removal of the last connected session
// of an always-on client
shouldDecrement := shouldDestroy || (alwaysOn && len(sessionsToDestroy) != 0 && len(client.sessions) == 0)
if shouldDestroy { if shouldDestroy {
// if it's our job to destroy it, don't let anyone else try // if it's our job to destroy it, don't let anyone else try
client.destroyed = true client.destroyed = true
@ -1237,7 +1239,7 @@ func (client *Client) destroy(session *Session) {
} }
// decrement stats if we have no more sessions, even if the client will not be destroyed // decrement stats if we have no more sessions, even if the client will not be destroyed
if shouldDestroy || (!alreadyDestroyed && remainingSessions == 0) { if shouldDecrement {
invisible := client.HasMode(modes.Invisible) invisible := client.HasMode(modes.Invisible)
operator := client.HasMode(modes.LocalOperator) || client.HasMode(modes.Operator) operator := client.HasMode(modes.LocalOperator) || client.HasMode(modes.Operator)
client.server.stats.Remove(registered, invisible, operator) client.server.stats.Remove(registered, invisible, operator)

View File

@ -179,8 +179,8 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
return "", errNicknameInUse return "", errNicknameInUse
} }
if numSessions == 1 { if numSessions == 1 {
invisible := client.HasMode(modes.Invisible) invisible := currentClient.HasMode(modes.Invisible)
operator := client.HasMode(modes.Operator) || client.HasMode(modes.LocalOperator) operator := currentClient.HasMode(modes.Operator) || currentClient.HasMode(modes.LocalOperator)
client.server.stats.AddRegistered(invisible, operator) client.server.stats.AddRegistered(invisible, operator)
} }
session.autoreplayMissedSince = lastSeen session.autoreplayMissedSince = lastSeen