Handle Errno::EALREADY exceptions on port checks
With WSL port checks can end up resulting in Errno::EALREADY being raised. When encountered, assume port is unavailable.
This commit is contained in:
parent
a1c2393e77
commit
16dc9db76b
@ -17,7 +17,7 @@ module Vagrant
|
||||
Socket.tcp(host, port, connect_timeout: 0.1).close
|
||||
true
|
||||
rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, \
|
||||
Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN
|
||||
Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN, Errno::EALREADY
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@ -55,4 +55,9 @@ describe Vagrant::Util::IsPortOpen do
|
||||
expect(Socket).to receive(:tcp).with("0.0.0.0", open_port, any_args).and_raise(Errno::EADDRNOTAVAIL)
|
||||
expect { subject.is_port_open?("0.0.0.0", open_port) }.to raise_error(Errno::EADDRNOTAVAIL)
|
||||
end
|
||||
|
||||
it "should treat operation already in progress as unavailable" do
|
||||
expect(Socket).to receive(:tcp).with("0.0.0.0", closed_port, any_args).and_raise(Errno::EALREADY)
|
||||
expect(subject.is_port_open?("0.0.0.0", closed_port)).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user