From 9b365567b602914e6417312403f28b79fd901a8d Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 13 Jun 2019 17:32:47 -0700 Subject: [PATCH] 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. --- watchtower/wtclient/client.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/watchtower/wtclient/client.go b/watchtower/wtclient/client.go index 7845d81e6..7b1653b9e 100644 --- a/watchtower/wtclient/client.go +++ b/watchtower/wtclient/client.go @@ -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 }