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