Handle a failed disconnect correctly
If the sender disconnects its socket before sending the disconnect message, the destination should restart the migration process. This patch makes sure that happens.
This commit is contained in:
36
tests/acceptance/fakes/dest/close_after_entrust_reply.rb
Executable file
36
tests/acceptance/fakes/dest/close_after_entrust_reply.rb
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env ruby
|
||||
# encoding: utf-8
|
||||
|
||||
# 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
|
||||
server = FakeDest.new( addr, port )
|
||||
client = server.accept
|
||||
|
||||
client.write_hello
|
||||
while (req = client.read_request; req[:type] == 1)
|
||||
client.read_data( req[:len] )
|
||||
client.write_reply( req[:handle] )
|
||||
end
|
||||
|
||||
system "kill -STOP #{src_pid}"
|
||||
client.write_reply( req[:handle] )
|
||||
client.close
|
||||
system "kill -CONT #{src_pid}"
|
||||
|
||||
sleep( 0.25 )
|
||||
client2 = server.accept( "Timed out waiting for a reconnection" )
|
||||
|
||||
client2.close
|
||||
server.close
|
||||
|
||||
$stderr.puts "done"
|
||||
exit(0)
|
||||
|
34
tests/acceptance/fakes/dest/error_on_entrust.rb
Executable file
34
tests/acceptance/fakes/dest/error_on_entrust.rb
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env ruby
|
||||
# encoding: utf-8
|
||||
|
||||
# Receive a mirror, but respond to the entrust with an error. There's
|
||||
# currently no code path in flexnbd which can do this, but we could
|
||||
# add one.
|
||||
|
||||
require 'flexnbd/fake_dest'
|
||||
include FlexNBD
|
||||
|
||||
addr, port = *ARGV
|
||||
server = FakeDest.new( addr, port )
|
||||
client = server.accept
|
||||
|
||||
client.write_hello
|
||||
loop do
|
||||
req = client.read_request
|
||||
if req[:type] == 1
|
||||
client.read_data( req[:len] )
|
||||
client.write_reply( req[:handle] )
|
||||
else
|
||||
client.write_reply( req[:handle], 1 )
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
client.close
|
||||
|
||||
client2 = server.accept( "Timed out waiting for a reconnection" )
|
||||
|
||||
client2.close
|
||||
server.close
|
||||
|
||||
exit(0)
|
Reference in New Issue
Block a user