* 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
Родитель c968f908e1
Коммит 569ca78e97
2 изменённых файлов: 22 добавлений и 14 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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