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

ruby-changes:46584

From: shugo <ko1@a...>
Date: Sat, 13 May 2017 11:05:46 +0900 (JST)
Subject: [ruby-changes:46584] shugo:r58700 (trunk): test/net/imap: fix race condition in test_exception_during_idle

shugo	2017-05-13 11:05:40 +0900 (Sat, 13 May 2017)

  New Revision: 58700

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58700

  Log:
    test/net/imap: fix race condition in test_exception_during_idle

  Modified files:
    trunk/test/net/imap/test_imap.rb
Index: test/net/imap/test_imap.rb
===================================================================
--- test/net/imap/test_imap.rb	(revision 58699)
+++ test/net/imap/test_imap.rb	(revision 58700)
@@ -240,7 +240,10 @@ class IMAPTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/imap/test_imap.rb#L240
             end
           end
           th.raise(Interrupt)
-          exception_raised = true
+          m.synchronize do
+            exception_raised = true
+            c.signal
+          end
         end
         imap.idle do |res|
           m.synchronize do
@@ -417,7 +420,7 @@ class IMAPTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/imap/test_imap.rb#L420
       begin
         m = Monitor.new
         in_idle = false
-        exception_raised = false
+        closed = false
         c = m.new_cond
         threads << Thread.start do
           m.synchronize do
@@ -426,14 +429,17 @@ class IMAPTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/imap/test_imap.rb#L429
             end
           end
           sock.close
-          exception_raised = true
+          m.synchronize do
+            closed = true
+            c.signal
+          end
         end
         assert_raise(Net::IMAP::Error) do
           imap.idle do |res|
             m.synchronize do
               in_idle = true
               c.signal
-              until exception_raised
+              until closed
                 c.wait(0.1)
               end
             end

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

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