From b7ff46b7a4690974e98d090e3e4de89ef73e533a Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 13 May 2017 02:05:40 +0000 Subject: test/net/imap: fix race condition in test_exception_during_idle git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/net/imap/test_imap.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'test/net/imap') diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb index 3224da65a1..9266cbdf81 100644 --- a/test/net/imap/test_imap.rb +++ b/test/net/imap/test_imap.rb @@ -240,7 +240,10 @@ class IMAPTest < Test::Unit::TestCase 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 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 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 -- cgit v1.2.3