Browse Source

fix always-on expiration checks

checkAlwaysOnExpirationNoMutex was respecting registered status, but
always-on clients were not considered registered at the time of the
initial check, so they were being created regardless of expiration.
tags/v2.5.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
6b7f0e15ac
2 changed files with 5 additions and 5 deletions
  1. 2
    2
      irc/client.go
  2. 3
    3
      irc/getters.go

+ 2
- 2
irc/client.go View File

443
 		nextSessionID: 1,
443
 		nextSessionID: 1,
444
 	}
444
 	}
445
 
445
 
446
-	if client.checkAlwaysOnExpirationNoMutex(config) {
446
+	if client.checkAlwaysOnExpirationNoMutex(config, true) {
447
 		server.logger.Debug("accounts", "always-on client not created due to expiration", account.Name)
447
 		server.logger.Debug("accounts", "always-on client not created due to expiration", account.Name)
448
 		return
448
 		return
449
 	}
449
 	}
1403
 	alwaysOn := registered && client.alwaysOn
1403
 	alwaysOn := registered && client.alwaysOn
1404
 	// if we hit always-on-expiration, confirm the expiration and then proceed as though
1404
 	// if we hit always-on-expiration, confirm the expiration and then proceed as though
1405
 	// always-on is disabled:
1405
 	// always-on is disabled:
1406
-	if alwaysOn && session == nil && client.checkAlwaysOnExpirationNoMutex(config) {
1406
+	if alwaysOn && session == nil && client.checkAlwaysOnExpirationNoMutex(config, false) {
1407
 		quitMessage = "Timed out due to inactivity"
1407
 		quitMessage = "Timed out due to inactivity"
1408
 		alwaysOn = false
1408
 		alwaysOn = false
1409
 		client.alwaysOn = false
1409
 		client.alwaysOn = false

+ 3
- 3
irc/getters.go View File

452
 func (client *Client) IsExpiredAlwaysOn(config *Config) (result bool) {
452
 func (client *Client) IsExpiredAlwaysOn(config *Config) (result bool) {
453
 	client.stateMutex.Lock()
453
 	client.stateMutex.Lock()
454
 	defer client.stateMutex.Unlock()
454
 	defer client.stateMutex.Unlock()
455
-	return client.checkAlwaysOnExpirationNoMutex(config)
455
+	return client.checkAlwaysOnExpirationNoMutex(config, false)
456
 }
456
 }
457
 
457
 
458
-func (client *Client) checkAlwaysOnExpirationNoMutex(config *Config) (result bool) {
459
-	if !(client.registered && client.alwaysOn) {
458
+func (client *Client) checkAlwaysOnExpirationNoMutex(config *Config, ignoreRegistration bool) (result bool) {
459
+	if !((client.registered || ignoreRegistration) && client.alwaysOn) {
460
 		return false
460
 		return false
461
 	}
461
 	}
462
 	deadline := time.Duration(config.Accounts.Multiclient.AlwaysOnExpiration)
462
 	deadline := time.Duration(config.Accounts.Multiclient.AlwaysOnExpiration)

Loading…
Cancel
Save