2012-06-22 10:05:41 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
# Wait for a sender connection, send a correct hello, then disconnect.
|
|
|
|
# Simulate a server which crashes after sending the hello. We then
|
|
|
|
# reopen the server socket to check that the sender retries: since the
|
|
|
|
# command-line has gone away, and can't feed an error back to the
|
|
|
|
# user, we have to keep trying.
|
|
|
|
|
2012-06-28 11:34:36 +01:00
|
|
|
require 'flexnbd/fake_dest'
|
|
|
|
include FlexNBD::FakeDest
|
2012-06-22 10:05:41 +01:00
|
|
|
|
2012-06-28 11:34:36 +01:00
|
|
|
addr, port = *ARGV
|
2012-06-22 10:05:41 +01:00
|
|
|
|
|
|
|
|
2012-06-28 11:34:36 +01:00
|
|
|
sock = serve( addr, port )
|
|
|
|
client_sock = accept( sock, "Timed out waiting for a connection" )
|
|
|
|
write_hello( client_sock )
|
2012-06-22 10:05:41 +01:00
|
|
|
client_sock.close
|
|
|
|
|
2012-06-28 11:34:36 +01:00
|
|
|
new_sock = accept( sock, "Timed out waiting for a reconnection" )
|
2012-06-22 10:05:41 +01:00
|
|
|
|
|
|
|
new_sock.close
|
|
|
|
sock.close
|
|
|
|
|
|
|
|
exit 0
|