2012-07-12 09:39:39 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# Receive a mirror, and disconnect after sending the entrust reply but
|
|
|
|
# before it can send the disconnect signal.
|
|
|
|
#
|
|
|
|
# This test is currently unused: the sender can't detect that the
|
|
|
|
# write failed.
|
|
|
|
|
|
|
|
require 'flexnbd/fake_dest'
|
|
|
|
include FlexNBD
|
|
|
|
|
|
|
|
addr, port, src_pid = *ARGV
|
2018-02-02 21:34:14 +00:00
|
|
|
server = FakeDest.new(addr, port)
|
2012-07-12 09:39:39 +01:00
|
|
|
client = server.accept
|
|
|
|
|
|
|
|
client.write_hello
|
2018-02-02 21:34:14 +00:00
|
|
|
while req = client.read_request; req[:type] == 1
|
|
|
|
client.read_data(req[:len])
|
|
|
|
client.write_reply(req[:handle])
|
2012-07-12 09:39:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
system "kill -STOP #{src_pid}"
|
2018-02-02 21:34:14 +00:00
|
|
|
client.write_reply(req[:handle])
|
2012-07-12 09:39:39 +01:00
|
|
|
client.close
|
|
|
|
system "kill -CONT #{src_pid}"
|
|
|
|
|
2018-02-02 21:34:14 +00:00
|
|
|
sleep(0.25)
|
|
|
|
client2 = server.accept('Timed out waiting for a reconnection')
|
2012-07-12 09:39:39 +01:00
|
|
|
|
|
|
|
client2.close
|
|
|
|
server.close
|
|
|
|
|
2018-02-02 21:34:14 +00:00
|
|
|
warn 'done'
|
2012-07-12 09:39:39 +01:00
|
|
|
exit(0)
|