Factor common code out of fake destinations
This commit is contained in:
@@ -2,20 +2,11 @@
|
||||
|
||||
# Accept a connection, then immediately close it. This simulates an ACL rejection.
|
||||
|
||||
addr, port = *ARGV
|
||||
require 'socket'
|
||||
require 'timeout'
|
||||
require 'flexnbd/fake_dest'
|
||||
include FlexNBD::FakeDest
|
||||
|
||||
serve_sock = TCPServer.open( addr, port )
|
||||
|
||||
begin
|
||||
Timeout.timeout( 2 ) do
|
||||
serve_sock.accept.close
|
||||
end
|
||||
rescue Timeout::Error
|
||||
$stderr.puts "Timed out waiting for a connection"
|
||||
exit 1
|
||||
end
|
||||
serve_sock = serve( *ARGV )
|
||||
accept( serve_sock, "Timed out waiting for a connection" ).close
|
||||
|
||||
serve_sock.close
|
||||
|
||||
|
Reference in New Issue
Block a user