ruby-changes:23706
From: naruse <ko1@a...>
Date: Tue, 22 May 2012 21:35:30 +0900 (JST)
Subject: [ruby-changes:23706] naruse:r35757 (trunk): rescue EPIPE raised from conn.print because of client's timeout
naruse 2012-05-22 21:35:18 +0900 (Tue, 22 May 2012) New Revision: 35757 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35757 Log: rescue EPIPE raised from conn.print because of client's timeout Modified files: trunk/test/net/ftp/test_ftp.rb Index: test/net/ftp/test_ftp.rb =================================================================== --- test/net/ftp/test_ftp.rb (revision 35756) +++ test/net/ftp/test_ftp.rb (revision 35757) @@ -327,19 +327,21 @@ sock.print("200 PORT command successful.\r\n") commands.push(sock.gets) sock.print("150 Here comes the directory listing.\r\n") - conn = TCPSocket.new(host, port) - list_lines.each_with_index do |l, i| - if i == 1 - sleep(0.5) - else - sleep(0.1) + begin + conn = TCPSocket.new(host, port) + list_lines.each_with_index do |l, i| + if i == 1 + sleep(0.5) + else + sleep(0.1) + end + conn.print(l, "\r\n") end - conn.print(l, "\r\n") + rescue Errno::EPIPE + ensure + assert_nil($!) + conn.close end - conn.shutdown(Socket::SHUT_WR) - conn.read_timeout = 1 - conn.read unless conn.eof? - conn.close sock.print("226 Directory send OK.\r\n") } begin -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/