From 42e9e734b962af6d12dbe742c3397be8d1002b46 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Sep 2014 14:03:57 -0700 Subject: [PATCH] common: don't wait SSH on first try --- CHANGELOG.md | 5 ++--- common/step_connect_ssh.go | 15 ++++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b94cf246..a6b904018 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,10 @@ FEATURES: * builder/vmware: VMware Fusion Pro 7 is now supported. [GH-1478] -IMPROVEMENTS: - BUG FIXES: - * build scripts: Windows executable renamed to packer.exe. [GH-1483] + * core: SSH will connect slightly faster if it is ready immediately. + * scripts: Windows executable renamed to packer.exe. [GH-1483] ## 0.7.0 (September 8, 2014) diff --git a/common/step_connect_ssh.go b/common/step_connect_ssh.go index fa2f7d64f..b00d5bfc0 100644 --- a/common/step_connect_ssh.go +++ b/common/step_connect_ssh.go @@ -98,13 +98,18 @@ func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, cancel <-chan stru handshakeAttempts := 0 var comm packer.Communicator + first := true for { - select { - case <-cancel: - log.Println("SSH wait cancelled. Exiting loop.") - return nil, errors.New("SSH wait cancelled") - case <-time.After(5 * time.Second): + // Don't check for cancel or wait on first iteration + if !first { + select { + case <-cancel: + log.Println("SSH wait cancelled. Exiting loop.") + return nil, errors.New("SSH wait cancelled") + case <-time.After(5 * time.Second): + } } + first = false // First we request the TCP connection information address, err := s.SSHAddress(state)