From 73dfbeb1d59fbc1e22651cb4da8ee85f0a6fd9ce Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 3 Jul 2012 17:57:44 -0700 Subject: blocking functions do not raise Errno::EINTR Blocking functions should not raise Errno::EINTR to match existing semantics of Ruby IO methods (e.g. IO.select, IO#read, IO#write). This makes user code easier to read/write. Like th Ruby methods we emulate, we only reacquire the GVL on EINTR to fire signal handlers, but otherwise emulate SA_RESTART semantics. This is a backwards-incompatible API change (but unlikely to break existing code). --- test/test_posix_mq.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb index 5b78c22..8d6b014 100644 --- a/test/test_posix_mq.rb +++ b/test/test_posix_mq.rb @@ -118,16 +118,18 @@ class Test_POSIX_MQ < Test::Unit::TestCase end alarm or return warn "alarm() not found in #{libcs.inspect}" alarms = 0 - trap("ALRM") { alarms += 1 } + trap("ALRM") do + alarms += 1 + Thread.new { @mq.send("HI") } + end interval = 1 alarm.call interval @mq = POSIX_MQ.new(@path, :rw) assert ! @mq.nonblock? t0 = Time.now - a = nil - assert_raises(Errno::EINTR) { a = @mq.receive } + a = @mq.receive elapsed = Time.now - t0 - assert_nil a + assert_equal(["HI", 0], a) assert elapsed >= interval, elapsed.inspect assert elapsed < 1.10, elapsed.inspect assert_equal 1, alarms -- cgit v1.2.3-24-ge0c7