Browse Source

fix #848

tags/v2.0.0
Shivaram Lingamneni 4 years ago
parent
commit
d50c4c2bd6
2 changed files with 8 additions and 6 deletions
  1. 6
    4
      irc/client.go
  2. 2
    2
      irc/client_lookup_set.go

+ 6
- 4
irc/client.go View File

1185
 
1185
 
1186
 	// should we destroy the whole client this time?
1186
 	// should we destroy the whole client this time?
1187
 	// BRB is not respected if this is a destroy of the whole client (i.e., session == nil)
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
 	if shouldDestroy {
1193
 	if shouldDestroy {
1192
 		// if it's our job to destroy it, don't let anyone else try
1194
 		// if it's our job to destroy it, don't let anyone else try
1193
 		client.destroyed = true
1195
 		client.destroyed = true
1237
 	}
1239
 	}
1238
 
1240
 
1239
 	// decrement stats if we have no more sessions, even if the client will not be destroyed
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
 		invisible := client.HasMode(modes.Invisible)
1243
 		invisible := client.HasMode(modes.Invisible)
1242
 		operator := client.HasMode(modes.LocalOperator) || client.HasMode(modes.Operator)
1244
 		operator := client.HasMode(modes.LocalOperator) || client.HasMode(modes.Operator)
1243
 		client.server.stats.Remove(registered, invisible, operator)
1245
 		client.server.stats.Remove(registered, invisible, operator)

+ 2
- 2
irc/client_lookup_set.go View File

179
 			return "", errNicknameInUse
179
 			return "", errNicknameInUse
180
 		}
180
 		}
181
 		if numSessions == 1 {
181
 		if numSessions == 1 {
182
-			invisible := client.HasMode(modes.Invisible)
183
-			operator := client.HasMode(modes.Operator) || client.HasMode(modes.LocalOperator)
182
+			invisible := currentClient.HasMode(modes.Invisible)
183
+			operator := currentClient.HasMode(modes.Operator) || currentClient.HasMode(modes.LocalOperator)
184
 			client.server.stats.AddRegistered(invisible, operator)
184
 			client.server.stats.AddRegistered(invisible, operator)
185
 		}
185
 		}
186
 		session.autoreplayMissedSince = lastSeen
186
 		session.autoreplayMissedSince = lastSeen

Loading…
Cancel
Save