From 1139ec9e0cf5e6cc944170dc918c00b72863b3ab Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 8 Mar 2010 19:17:43 -0800 Subject: [PATCH] SSH.up? actually times out properly now --- lib/vagrant/ssh.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 800753ac6..d9979b2df 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -26,13 +26,19 @@ module Vagrant end def up? - Net::SSH.start(Vagrant.config.ssh.host, Vagrant.config.ssh.username, :port => port, :password => Vagrant.config.ssh.password, :timeout => 5) do |ssh| - return true + check_thread = Thread.new do + begin + Thread.current[:result] = false + Net::SSH.start(Vagrant.config.ssh.host, Vagrant.config.ssh.username, :port => port, :password => Vagrant.config.ssh.password, :timeout => 5) do |ssh| + Thread.current[:result] = true + end + rescue Errno::ECONNREFUSED, Net::SSH::Disconnect + # False, its defaulted above + end end - false - rescue Errno::ECONNREFUSED, Net::SSH::Disconnect - false + check_thread.join(5) + return check_thread[:result] end def port(opts={})