about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-01-02 20:41:39 -0800
committerEric Wong <normalperson@yhbt.net>2010-01-02 20:57:54 -0800
commit6f24b5626f89fbb6445c0943ba71f56c8945e18f (patch)
tree62a739ddbb2a792a4864f7e5f7c97368e816d30e /test
parent522d4d1472c216bd95a16ca5b118bc14693aad64 (diff)
downloadruby_posix_mq-6f24b5626f89fbb6445c0943ba71f56c8945e18f.tar.gz
"mq.notify = false" also works now, doing what
"mq.notify = nil" used to do (using SIGEV_NONE).

I was confused by SIGEV_NONE usage vs using a NULL pointer for
the notification passed mq_notify(3).  SIGEV_NONE does not
actually unregister, it registers a no-op notification which
prevents other processes from taking us.

This also fixes the test case to pass under both Linux and
FreeBSD.
Diffstat (limited to 'test')
-rw-r--r--test/test_posix_mq.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index 00b0f5a..dccc547 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -136,11 +136,27 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     assert_nil(@mq.notify = nil)
     assert_nothing_raised { @mq.send("hello", 0) }
     assert_nil IO.select([rd], nil, nil, 0.1)
-    assert_raises(Errno::EBUSY) { @mq.notify = :USR1 }
     ensure
       trap(:USR1, orig)
   end
 
+  def test_notify_none
+    @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
+    assert_nothing_raised { @mq.notify = false }
+    pid = fork do
+      begin
+        @mq.notify = :USR1
+      rescue Errno::EBUSY
+        exit 0
+      rescue => e
+        p e
+      end
+      exit! 1
+    end
+    _, status = Process.waitpid2(pid)
+    assert status.success?, status.inspect
+  end
+
   def test_setattr
     @mq = POSIX_MQ.new @path, IO::CREAT|IO::WRONLY, 0666
     mq_attr = POSIX_MQ::Attr.new(IO::NONBLOCK)