lib/vagrant/ssh.rb in vagrant-0.8.1 vs lib/vagrant/ssh.rb in vagrant-0.8.2

- old
+ new

@@ -71,11 +71,25 @@ opts = opts.dup opts[:forward_agent] = true if env.config.ssh.forward_agent opts[:port] ||= port # Check if we have a currently open SSH session which has the - # same options, and use that if possible - session, options = @current_session + # same options, and use that if possible. + # + # NOTE: This is experimental and unstable. Therefore it is disabled + # by default. + session, options = nil + session, options = @current_session if env.config.vagrant.ssh_session_cache + + if session && options == opts + # Verify that the SSH session is still valid + begin + session.exec!("echo foo") + rescue IOError + # Reset the session, we need to reconnect + session = nil + end + end if !session || options != opts env.logger.info("ssh") { "Connecting to SSH: #{env.config.ssh.host} #{opts[:port]}" } # The exceptions which are acceptable to retry on during