2012-06-28 14:45:53 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# encoding: utf-8
|
|
|
|
|
2012-07-02 13:00:30 +01:00
|
|
|
# Open a socket, say hello, receive a write, then sleep for >
|
|
|
|
# MS_REQUEST_LIMIT_SECS seconds. This should tell the source that the
|
|
|
|
# write has gone MIA, and we expect a reconnect.
|
2012-06-28 14:45:53 +01:00
|
|
|
|
|
|
|
require 'flexnbd/fake_dest'
|
2012-07-02 15:04:45 +01:00
|
|
|
include FlexNBD
|
2012-06-28 14:45:53 +01:00
|
|
|
|
2012-07-03 15:25:39 +01:00
|
|
|
addr, port = *ARGV
|
|
|
|
server = FakeDest.new( addr, port )
|
2012-07-02 15:04:45 +01:00
|
|
|
client1 = server.accept( server )
|
|
|
|
client1.write_hello
|
|
|
|
client1.read_request
|
2012-06-28 14:45:53 +01:00
|
|
|
|
|
|
|
t = Thread.start do
|
2012-07-02 15:04:45 +01:00
|
|
|
client2 = server.accept( "Timed out waiting for a reconnection",
|
2012-07-02 13:00:30 +01:00
|
|
|
FlexNBD::MS_REQUEST_LIMIT_SECS + 2 )
|
2012-07-02 15:04:45 +01:00
|
|
|
client2.close
|
2012-06-28 14:45:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
sleep( FlexNBD::MS_REQUEST_LIMIT_SECS + 2 )
|
2012-07-02 15:04:45 +01:00
|
|
|
client1.close
|
2012-06-28 14:45:53 +01:00
|
|
|
|
|
|
|
t.join
|
|
|
|
|
2012-07-02 15:04:45 +01:00
|
|
|
server.close
|
2012-06-28 14:45:53 +01:00
|
|
|
exit(0)
|