rebalanceTimer may be nil during initialization

When first starting the server manager, it's possible that the rebalanceTimer in serverConfig will be nil, test accordingly.
This commit is contained in:
Sean Chittenden 2016-02-19 19:00:23 -08:00
parent a7091b0837
commit e6c27325d9
1 changed files with 5 additions and 1 deletions

View File

@ -292,7 +292,11 @@ func (sc *serverConfig) resetRebalanceTimer(sm *ServerManager) {
connRebalanceTimeout := lib.RateScaledInterval(clusterWideRebalanceConnsPerSec, connReuseLowWatermarkDuration, numLANMembers)
sm.logger.Printf("[DEBUG] consul: connection will be rebalanced in %v", connRebalanceTimeout)
sc.rebalanceTimer.Reset(connRebalanceTimeout)
if sc.rebalanceTimer == nil {
sc.rebalanceTimer = time.NewTimer(connRebalanceTimeout)
} else {
sc.rebalanceTimer.Reset(connRebalanceTimeout)
}
}
// StartServerManager is used to start and manage the task of automatically