From 9d0af9dbfea5b1ddf906281cc3cb7fb62b4c8dfb Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 10 Sep 2014 14:18:41 +0100 Subject: [PATCH] Keep targets around until their attempt fails --- connection_maker.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/connection_maker.go b/connection_maker.go index 3fb7eb7e..f026918a 100644 --- a/connection_maker.go +++ b/connection_maker.go @@ -141,15 +141,17 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) { }) for address, target := range cm.targets { - if validTarget[address] { - if target.state == CSUnconnected && now.After(target.tryAfter) { - target.attemptCount += 1 - target.state = CSAttempting - go cm.attemptConnection(address, cm.cmdLineAddress[address]) + if target.state == CSUnconnected { + if validTarget[address] { + if now.After(target.tryAfter) { + target.attemptCount += 1 + target.state = CSAttempting + go cm.attemptConnection(address, cm.cmdLineAddress[address]) + } + } else { + //log.Println("Deleting target no longer valid:", address) + delete(cm.targets, address) } - } else { - //log.Println("Deleting target no longer valid:", address) - delete(cm.targets, address) } } }