Close the mirror client socket on rejection
If the mirror attempt connects ok, but is rejected (say, for reporting the wrong size), the client socket needs to be closed. The destination end can't close its socket and accept another connection attempt unless it does.
This commit is contained in:
@@ -21,4 +21,9 @@ client.write_hello( :size => :wrong )
|
||||
|
||||
t.join
|
||||
|
||||
# Now check that the source closed the first socket (yes, this was an
|
||||
# actual bug)
|
||||
|
||||
fail "Didn't close socket" unless client.disconnected?
|
||||
|
||||
exit 0
|
||||
|
@@ -62,6 +62,15 @@ module FlexNBD
|
||||
write_reply( handle, 1 )
|
||||
end
|
||||
|
||||
def disconnected?
|
||||
begin
|
||||
Timeout.timeout(2) do
|
||||
@sock.read(1) == nil
|
||||
end
|
||||
rescue Timeout::Error
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def write_reply( handle, err=0, opts={} )
|
||||
if opts[:magic] == :wrong
|
||||
|
Reference in New Issue
Block a user