watchtower/wtclient/client: avoid over requesting sessions
This commit fixes a bug that would cause us to request more sessions that needed from the session negotiator. With the current stat ticker, we'd ask the negotiator for a new session every 30s if session session negotiation did not return before printing the stats. Now we'll avoid requesting to sessions by jumping back into the select loop.
This commit is contained in:
parent
72e355f933
commit
9b365567b6
@ -566,6 +566,7 @@ func (c *TowerClient) backupDispatcher() {
|
||||
// Wait until we receive the newly negotiated session.
|
||||
// All backups sent in the meantime are queued in the
|
||||
// revoke queue, as we cannot process them.
|
||||
awaitSession:
|
||||
select {
|
||||
case session := <-c.negotiator.NewSessions():
|
||||
log.Infof("Acquired new session with id=%s",
|
||||
@ -576,6 +577,12 @@ func (c *TowerClient) backupDispatcher() {
|
||||
case <-c.statTicker.C:
|
||||
log.Infof("Client stats: %s", c.stats)
|
||||
|
||||
// Instead of looping, we'll jump back into the
|
||||
// select case and await the delivery of the
|
||||
// session to prevent us from re-requesting
|
||||
// additional sessions.
|
||||
goto awaitSession
|
||||
|
||||
case <-c.forceQuit:
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user