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

ruby-changes:10738

From: akr <ko1@a...>
Date: Sat, 14 Feb 2009 20:06:28 +0900 (JST)
Subject: [ruby-changes:10738] Ruby:r22302 (trunk): add timeout.

akr	2009-02-14 20:06:23 +0900 (Sat, 14 Feb 2009)

  New Revision: 22302

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

  Log:
    add timeout.

  Modified files:
    trunk/test/socket/test_socket.rb

Index: test/socket/test_socket.rb
===================================================================
--- test/socket/test_socket.rb	(revision 22301)
+++ test/socket/test_socket.rb	(revision 22302)
@@ -251,6 +251,9 @@
           Addrinfo.udp(ai.ip_address, port).connect {|s|
             msg1 = "<<<#{ai.inspect}>>>"
             s.sendmsg msg1
+            unless IO.select([s], nil, nil, 10)
+              raise "no response"
+            end
             msg2, addr = s.recvmsg
             msg2, remote_address, local_address = Marshal.load(msg2)
             assert_equal(msg1, msg2)
@@ -260,7 +263,11 @@
       ensure
         if th
           Addrinfo.udp("127.0.0.1", port).connect {|s| s.sendmsg "exit" }
-          th.join
+          unless th.join(10)
+            Thread.kill th
+            th.join(10)
+            raise "thread killed"
+          end
         end
       end
     }

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

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