瀏覽代碼

Merge pull request #849 from slingamn/issue848_lusers_again.1

fix #848
tags/v2.0.0
Shivaram Lingamneni 4 年之前
父節點
當前提交
b68b28e189
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 8 行新增6 行删除
  1. 6
    4
      irc/client.go
  2. 2
    2
      irc/client_lookup_set.go

+ 6
- 4
irc/client.go 查看文件

@@ -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)

+ 2
- 2
irc/client_lookup_set.go 查看文件

@@ -179,8 +179,8 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
179 179
 			return "", errNicknameInUse
180 180
 		}
181 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 184
 			client.server.stats.AddRegistered(invisible, operator)
185 185
 		}
186 186
 		session.autoreplayMissedSince = lastSeen

Loading…
取消
儲存