From a629f1655b3ded11a628422b278b85c2b8ee2969 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 28 Apr 2014 15:25:59 -0700 Subject: [PATCH] communicator/ssh: remove background connection checker Updated SSH package is supposed to be able to detect remote connection closes now, which is nice. --- communicator/ssh/communicator.go | 40 -------------------------------- 1 file changed, 40 deletions(-) diff --git a/communicator/ssh/communicator.go b/communicator/ssh/communicator.go index f242916bf..e07f875c6 100644 --- a/communicator/ssh/communicator.go +++ b/communicator/ssh/communicator.go @@ -14,7 +14,6 @@ import ( "os" "path/filepath" "sync" - "time" ) type comm struct { @@ -117,45 +116,6 @@ func (c *comm) Start(cmd *packer.RemoteCmd) (err error) { close(doneCh) }() - go func() { - failures := 0 - for { - log.Printf("[DEBUG] Background SSH connection checker is testing") - dummy, err := c.config.Connection() - if err == nil { - failures = 0 - dummy.Close() - } - - select { - case <-doneCh: - return - default: - } - - if err != nil { - log.Printf("background SSH connection checker failure: %s", err) - failures += 1 - } - - if failures < 5 { - time.Sleep(5 * time.Second) - continue - } - - // Acquire a lock in order to modify session state - sessionLock.Lock() - defer sessionLock.Unlock() - - // Kill the connection and mark that we timed out. - log.Printf("Too many SSH connection failures. Killing it!") - c.conn.Close() - timedOut = true - - return - } - }() - return }