mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Shutdown gracefully.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
03570f8091
commit
d795f2d1a8
2 changed files with 14 additions and 0 deletions
|
@ -433,6 +433,8 @@ module Net
|
||||||
end
|
end
|
||||||
conn = BufferedSocket.new(sock.accept)
|
conn = BufferedSocket.new(sock.accept)
|
||||||
conn.read_timeout = @read_timeout
|
conn.read_timeout = @read_timeout
|
||||||
|
sock.shutdown(Socket::SHUT_WR)
|
||||||
|
sock.read rescue nil
|
||||||
sock.close
|
sock.close
|
||||||
end
|
end
|
||||||
return conn
|
return conn
|
||||||
|
@ -487,6 +489,9 @@ module Net
|
||||||
break if data == nil
|
break if data == nil
|
||||||
yield(data)
|
yield(data)
|
||||||
end
|
end
|
||||||
|
conn.shutdown(Socket::SHUT_WR)
|
||||||
|
conn.read_timeout = 1
|
||||||
|
conn.read
|
||||||
conn.close
|
conn.close
|
||||||
voidresp
|
voidresp
|
||||||
end
|
end
|
||||||
|
@ -508,6 +513,9 @@ module Net
|
||||||
break if line == nil
|
break if line == nil
|
||||||
yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?)
|
yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?)
|
||||||
end
|
end
|
||||||
|
conn.shutdown(Socket::SHUT_WR)
|
||||||
|
conn.read_timeout = 1
|
||||||
|
conn.read
|
||||||
conn.close
|
conn.close
|
||||||
voidresp
|
voidresp
|
||||||
end
|
end
|
||||||
|
|
|
@ -271,6 +271,8 @@ class FTPTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
conn.print(l, "\r\n")
|
conn.print(l, "\r\n")
|
||||||
end
|
end
|
||||||
|
conn.shutdown(Socket::SHUT_WR)
|
||||||
|
conn.read
|
||||||
conn.close
|
conn.close
|
||||||
sock.print("226 Directory send OK.\r\n")
|
sock.print("226 Directory send OK.\r\n")
|
||||||
}
|
}
|
||||||
|
@ -398,6 +400,7 @@ class FTPTest < Test::Unit::TestCase
|
||||||
buf << s
|
buf << s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
assert_equal(1024, buf.bytesize)
|
||||||
assert_equal(binary_data[0, 1024], buf)
|
assert_equal(binary_data[0, 1024], buf)
|
||||||
assert_match(/\APORT /, commands.shift)
|
assert_match(/\APORT /, commands.shift)
|
||||||
assert_equal("RETR foo\r\n", commands.shift)
|
assert_equal("RETR foo\r\n", commands.shift)
|
||||||
|
@ -434,6 +437,8 @@ class FTPTest < Test::Unit::TestCase
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
conn.print(s)
|
conn.print(s)
|
||||||
end
|
end
|
||||||
|
conn.shutdown(Socket::SHUT_WR)
|
||||||
|
conn.read
|
||||||
conn.close
|
conn.close
|
||||||
sock.print("226 Transfer complete.\r\n")
|
sock.print("226 Transfer complete.\r\n")
|
||||||
}
|
}
|
||||||
|
@ -450,6 +455,7 @@ class FTPTest < Test::Unit::TestCase
|
||||||
ftp.retrbinary("RETR foo", 1024) do |s|
|
ftp.retrbinary("RETR foo", 1024) do |s|
|
||||||
buf << s
|
buf << s
|
||||||
end
|
end
|
||||||
|
assert_equal(binary_data.bytesize, buf.bytesize)
|
||||||
assert_equal(binary_data, buf)
|
assert_equal(binary_data, buf)
|
||||||
assert_match(/\APORT /, commands.shift)
|
assert_match(/\APORT /, commands.shift)
|
||||||
assert_equal("RETR foo\r\n", commands.shift)
|
assert_equal("RETR foo\r\n", commands.shift)
|
||||||
|
|
Loading…
Add table
Reference in a new issue