[前][次][番号順一覧][スレッド一覧]

ruby-changes:23681

From: naruse <ko1@a...>
Date: Mon, 21 May 2012 06:57:11 +0900 (JST)
Subject: [ruby-changes:23681] naruse:r35732 (trunk): Shutdown gracefully.

naruse	2012-05-21 06:56:40 +0900 (Mon, 21 May 2012)

  New Revision: 35732

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35732

  Log:
    Shutdown gracefully.

  Modified files:
    trunk/lib/net/ftp.rb
    trunk/test/net/ftp/test_ftp.rb

Index: lib/net/ftp.rb
===================================================================
--- lib/net/ftp.rb	(revision 35731)
+++ lib/net/ftp.rb	(revision 35732)
@@ -433,6 +433,8 @@
         end
         conn = BufferedSocket.new(sock.accept)
         conn.read_timeout = @read_timeout
+        sock.shutdown(Socket::SHUT_WR)
+        sock.read rescue nil
         sock.close
       end
       return conn
@@ -487,6 +489,9 @@
             break if data == nil
             yield(data)
           end
+          conn.shutdown(Socket::SHUT_WR)
+          conn.read_timeout = 1
+          conn.read
           conn.close
           voidresp
         end
@@ -508,6 +513,9 @@
             break if line == nil
             yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?)
           end
+          conn.shutdown(Socket::SHUT_WR)
+          conn.read_timeout = 1
+          conn.read
           conn.close
           voidresp
         end
Index: test/net/ftp/test_ftp.rb
===================================================================
--- test/net/ftp/test_ftp.rb	(revision 35731)
+++ test/net/ftp/test_ftp.rb	(revision 35732)
@@ -271,6 +271,8 @@
         end
         conn.print(l, "\r\n")
       end
+      conn.shutdown(Socket::SHUT_WR)
+      conn.read
       conn.close
       sock.print("226 Directory send OK.\r\n")
     }
@@ -398,6 +400,7 @@
             buf << s
           end
         end
+        assert_equal(1024, buf.bytesize)
         assert_equal(binary_data[0, 1024], buf)
         assert_match(/\APORT /, commands.shift)
         assert_equal("RETR foo\r\n", commands.shift)
@@ -434,6 +437,8 @@
         sleep(0.1)
         conn.print(s)
       end
+      conn.shutdown(Socket::SHUT_WR)
+      conn.read
       conn.close
       sock.print("226 Transfer complete.\r\n")
     }
@@ -450,6 +455,7 @@
         ftp.retrbinary("RETR foo", 1024) do |s|
           buf << s
         end
+        assert_equal(binary_data.bytesize, buf.bytesize)
         assert_equal(binary_data, buf)
         assert_match(/\APORT /, commands.shift)
         assert_equal("RETR foo\r\n", commands.shift)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]