Test that a write reply with the wrong magic will force a retry
This commit is contained in:
@@ -56,10 +56,21 @@ module FlexNBD
|
||||
}
|
||||
end
|
||||
|
||||
REPLY_MAGIC="\x67\x44\x66\x98"
|
||||
|
||||
def write_error( handle )
|
||||
@sock.write( "\x67\x44\x66\x98" )
|
||||
@sock.write( "\x00\x00\x00\x01" )
|
||||
write_reply( handle, 1 )
|
||||
end
|
||||
|
||||
|
||||
def write_reply( handle, err=0, opts={} )
|
||||
if opts[:magic] == :wrong
|
||||
write_rand( @sock, 4 )
|
||||
else
|
||||
@sock.write( REPLY_MAGIC )
|
||||
end
|
||||
|
||||
@sock.write( [err].pack("N") )
|
||||
@sock.write( handle )
|
||||
end
|
||||
|
||||
@@ -69,6 +80,10 @@ module FlexNBD
|
||||
end
|
||||
|
||||
|
||||
def read_data( len )
|
||||
@sock.read( len )
|
||||
end
|
||||
|
||||
|
||||
def self.parse_be64(str)
|
||||
raise "String is the wrong length: 8 bytes expected (#{str.length} received)" unless
|
||||
|
Reference in New Issue
Block a user