1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/net/ftp.rb (transfercmd): Close TCP server socket even if an

exception occur.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2014-05-27 15:14:59 +00:00
parent c968f908e1
commit 569ca78e97
2 changed files with 22 additions and 14 deletions

View file

@ -1,3 +1,8 @@
Wed May 28 00:06:18 2014 Tanaka Akira <akr@fsij.org>
* lib/net/ftp.rb (transfercmd): Close TCP server socket even if an
exception occur.
Tue May 27 23:50:07 2014 Tanaka Akira <akr@fsij.org>
* lib/cgi/core.rb: Use Tempfile#close(true) instead of Tempfile#unlink

View file

@ -420,23 +420,26 @@ module Net
end
else
sock = makeport
if @resume and rest_offset
resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != ?3
begin
if @resume and rest_offset
resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != ?3
raise FTPReplyError, resp
end
end
resp = sendcmd(cmd)
# skip 2XX for some ftp servers
resp = getresp if resp[0] == ?2
if resp[0] != ?1
raise FTPReplyError, resp
end
conn = BufferedSocket.new(sock.accept)
conn.read_timeout = @read_timeout
sock.shutdown(Socket::SHUT_WR) rescue nil
sock.read rescue nil
ensure
sock.close
end
resp = sendcmd(cmd)
# skip 2XX for some ftp servers
resp = getresp if resp[0] == ?2
if resp[0] != ?1
raise FTPReplyError, resp
end
conn = BufferedSocket.new(sock.accept)
conn.read_timeout = @read_timeout
sock.shutdown(Socket::SHUT_WR) rescue nil
sock.read rescue nil
sock.close
end
return conn
end