* [PATCH 1/3] Fix call to DL::Function.new in tests
@ 2012-07-03 20:13 Hleb Valoshka
2012-07-03 20:13 ` [PATCH 2/3] Add libc names for Debian GNU/kFreeBSD and FreeBSD " Hleb Valoshka
2012-07-03 20:13 ` [PATCH 3/3] Add a sleep in alarm test in current Ruby Hleb Valoshka
0 siblings, 2 replies; 12+ messages in thread
From: Hleb Valoshka @ 2012-07-03 20:13 UTC (permalink / raw)
To: ruby.posix.mq
The 3rd argument of DL::Function.new is ABI type, not a return type.
---
test/test_posix_mq.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index d48238c..5c7cc11 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -110,7 +110,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
if defined?(DL::Function)
alarm = libc["alarm"]
alarm = DL::CFunc.new(alarm, DL::TYPE_INT, "alarm")
- alarm = DL::Function.new(alarm, [DL::TYPE_INT], DL::TYPE_INT)
+ alarm = DL::Function.new(alarm, [DL::TYPE_INT])
else
alarm = libc["alarm", "II"]
end
--
1.7.10
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] Add libc names for Debian GNU/kFreeBSD and FreeBSD in tests.
2012-07-03 20:13 [PATCH 1/3] Fix call to DL::Function.new in tests Hleb Valoshka
@ 2012-07-03 20:13 ` Hleb Valoshka
2012-07-03 20:13 ` [PATCH 3/3] Add a sleep in alarm test in current Ruby Hleb Valoshka
1 sibling, 0 replies; 12+ messages in thread
From: Hleb Valoshka @ 2012-07-03 20:13 UTC (permalink / raw)
To: ruby.posix.mq
---
test/test_posix_mq.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index 5c7cc11..5b78c22 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -104,7 +104,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
def test_alarm_signal_safe
libc = alarm = nil
- libcs = %w(libc.so.6 /usr/lib/libc.sl)
+ libcs = %w(libc.so.6 libc.so.0.1 libc.so.7 /usr/lib/libc.sl)
libcs.each do |name|
libc = DL::Handle.new(name) rescue next
if defined?(DL::Function)
--
1.7.10
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-03 20:13 [PATCH 1/3] Fix call to DL::Function.new in tests Hleb Valoshka
2012-07-03 20:13 ` [PATCH 2/3] Add libc names for Debian GNU/kFreeBSD and FreeBSD " Hleb Valoshka
@ 2012-07-03 20:13 ` Hleb Valoshka
2012-07-04 0:20 ` Eric Wong
1 sibling, 1 reply; 12+ messages in thread
From: Hleb Valoshka @ 2012-07-03 20:13 UTC (permalink / raw)
To: ruby.posix.mq
Without that sleep alarms will be 0. Looks like Ruby VM issue.
---
test/test_posix_mq.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index 5b78c22..98feff2 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -127,6 +127,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
a = nil
assert_raises(Errno::EINTR) { a = @mq.receive }
elapsed = Time.now - t0
+ sleep 0.01 if RUBY_VERSION >= '1.9'
assert_nil a
assert elapsed >= interval, elapsed.inspect
assert elapsed < 1.10, elapsed.inspect
--
1.7.10
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-03 20:13 ` [PATCH 3/3] Add a sleep in alarm test in current Ruby Hleb Valoshka
@ 2012-07-04 0:20 ` Eric Wong
2012-07-04 0:59 ` Eric Wong
2012-07-04 13:39 ` Hleb Valoshka
0 siblings, 2 replies; 12+ messages in thread
From: Eric Wong @ 2012-07-04 0:20 UTC (permalink / raw)
To: ruby.posix.mq
Hleb Valoshka <375gnu@gmail.com> wrote:
> Without that sleep alarms will be 0. Looks like Ruby VM issue.
Thanks, your other two patches look good and I've pushed them.
Can you elaborate on this issue?
I would like to see a bug report/analysis to Ruby upstream
(and or EGLIBC) maintainers.
I assume this only happens on GNU/kFreeBSD?
> --- a/test/test_posix_mq.rb
> +++ b/test/test_posix_mq.rb
> @@ -127,6 +127,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
> a = nil
> assert_raises(Errno::EINTR) { a = @mq.receive }
> elapsed = Time.now - t0
> + sleep 0.01 if RUBY_VERSION >= '1.9'
> assert_nil a
> assert elapsed >= interval, elapsed.inspect
> assert elapsed < 1.10, elapsed.inspect
Fwiw, I'm not sure if this is a good test, either. Since I
wrote this code, I've come to believe normal API methods should
not raise Errno::EINTR. I've changed a few of my other libraries
(sleepy_penguin, kgio) to avoid EINTR but missed this one.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-04 0:20 ` Eric Wong
@ 2012-07-04 0:59 ` Eric Wong
2012-07-04 13:39 ` Hleb Valoshka
1 sibling, 0 replies; 12+ messages in thread
From: Eric Wong @ 2012-07-04 0:59 UTC (permalink / raw)
To: ruby.posix.mq
Eric Wong <normalperson@yhbt.net> wrote:
> Fwiw, I'm not sure if this is a good test, either. Since I
> wrote this code, I've come to believe normal API methods should
> not raise Errno::EINTR. I've changed a few of my other libraries
> (sleepy_penguin, kgio) to avoid EINTR but missed this one.
Something like this
>From 535c9541fdba10a9572b63efc0d0502d009da94c Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson@yhbt.net>
Date: Tue, 3 Jul 2012 17:57:44 -0700
Subject: [PATCH] change blocking functions to not return EINTR
This is an API change.
---
ext/posix_mq/posix_mq.c | 12 +++++++++++-
test/test_posix_mq.rb | 10 ++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c
index 2958352..df667e3 100644
--- a/ext/posix_mq/posix_mq.c
+++ b/ext/posix_mq/posix_mq.c
@@ -542,8 +542,11 @@ static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self)
x.timeout = convert_timeout(&expire, timeout);
x.msg_prio = NIL_P(prio) ? 0 : NUM2UINT(prio);
+retry:
rv = (mqd_t)rb_thread_blocking_region(xsend, &x, RUBY_UBF_IO, 0);
if (rv == MQD_INVALID) {
+ if (errno == EINTR)
+ goto retry;
if (errno == EAGAIN && (sflags & PMQ_TRY))
return Qfalse;
rb_sys_fail("mq_send");
@@ -574,9 +577,13 @@ static VALUE send0(VALUE self, VALUE buffer)
x.timeout = NULL;
x.msg_prio = 0;
+retry:
rv = (mqd_t)rb_thread_blocking_region(xsend, &x, RUBY_UBF_IO, 0);
- if (rv == MQD_INVALID)
+ if (rv == MQD_INVALID) {
+ if (errno == EINTR)
+ goto retry;
rb_sys_fail("mq_send");
+ }
return self;
}
@@ -678,8 +685,11 @@ static VALUE _receive(int rflags, int argc, VALUE *argv, VALUE self)
x.msg_len = (size_t)mq->attr.mq_msgsize;
x.des = mq->des;
+retry:
r = (ssize_t)rb_thread_blocking_region(xrecv, &x, RUBY_UBF_IO, 0);
if (r < 0) {
+ if (errno == EINTR)
+ goto retry;
if (errno == EAGAIN && (rflags & PMQ_TRY))
return Qnil;
rb_sys_fail("mq_receive");
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
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-04 0:20 ` Eric Wong
2012-07-04 0:59 ` Eric Wong
@ 2012-07-04 13:39 ` Hleb Valoshka
2012-07-12 8:03 ` Hleb Valoshka
2012-07-13 7:21 ` Eric Wong
1 sibling, 2 replies; 12+ messages in thread
From: Hleb Valoshka @ 2012-07-04 13:39 UTC (permalink / raw)
To: ruby.posix.mq
[-- Attachment #1: Type: text/plain, Size: 489 bytes --]
On 7/4/12, Eric Wong <normalperson@yhbt.net> wrote:
> Can you elaborate on this issue?
I'll try, but I don't promise a result, cause I don't have enough knowledge :)
> I assume this only happens on GNU/kFreeBSD?
No, It's on GNU/Linux. On GNU/kFreeBSD I have "Errno::ENOSYS: Function
not implemented - mq_open" (yes, I've made "kldload mqueuefs).
On ordinal FreeBSD 9.0 this assert is successful but there other
problems. You may look attachments, out.1 is stdout and out.2 is
stderr.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-04 13:39 ` Hleb Valoshka
@ 2012-07-12 8:03 ` Hleb Valoshka
2012-07-12 8:09 ` Eric Wong
2012-07-13 7:21 ` Eric Wong
1 sibling, 1 reply; 12+ messages in thread
From: Hleb Valoshka @ 2012-07-12 8:03 UTC (permalink / raw)
To: ruby.posix.mq
This issue can be reproduced with 3 simple LOC
mkfifo myfifo
ruby -e "a=0;trap(:USR2) {a+=1}; IO.readlines('myfifo') rescue nil; puts a"
killall -USR2 ruby
And it affects only GNU/Linux and OpenBSD but not FreeBSD or GNU/kFreeBSD.
I've filed an issue: https://bugs.ruby-lang.org/issues/6725
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-12 8:03 ` Hleb Valoshka
@ 2012-07-12 8:09 ` Eric Wong
2012-07-12 13:46 ` Hleb Valoshka
0 siblings, 1 reply; 12+ messages in thread
From: Eric Wong @ 2012-07-12 8:09 UTC (permalink / raw)
To: ruby.posix.mq
Hleb Valoshka <375gnu@gmail.com> wrote:
> This issue can be reproduced with 3 simple LOC
>
> mkfifo myfifo
> ruby -e "a=0;trap(:USR2) {a+=1}; IO.readlines('myfifo') rescue nil; puts a"
> killall -USR2 ruby
>
> And it affects only GNU/Linux and OpenBSD but not FreeBSD or GNU/kFreeBSD.
>
> I've filed an issue: https://bugs.ruby-lang.org/issues/6725
Odd, thanks!
Btw, I've also pushed out the Errno::EINTR-avoidance patch.
I'm still hoping to have more time to look at the FreeBSD9 issues
you've reported.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-12 8:09 ` Eric Wong
@ 2012-07-12 13:46 ` Hleb Valoshka
2012-07-12 19:46 ` Eric Wong
0 siblings, 1 reply; 12+ messages in thread
From: Hleb Valoshka @ 2012-07-12 13:46 UTC (permalink / raw)
To: ruby.posix.mq
On 7/12/12, Eric Wong <normalperson@yhbt.net> wrote:
>> I've filed an issue: https://bugs.ruby-lang.org/issues/6725
Bug report is rejected with the following explanation: "Asynchronous signals may
not dealt with in the order you expect."
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-12 13:46 ` Hleb Valoshka
@ 2012-07-12 19:46 ` Eric Wong
0 siblings, 0 replies; 12+ messages in thread
From: Eric Wong @ 2012-07-12 19:46 UTC (permalink / raw)
To: ruby.posix.mq
Hleb Valoshka <375gnu@gmail.com> wrote:
> On 7/12/12, Eric Wong <normalperson@yhbt.net> wrote:
>
> >> I've filed an issue: https://bugs.ruby-lang.org/issues/6725
>
> Bug report is rejected with the following explanation: "Asynchronous signals may
> not dealt with in the order you expect."
True, I don't disagree with upstream... Signal handlers are tricky :<
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-04 13:39 ` Hleb Valoshka
2012-07-12 8:03 ` Hleb Valoshka
@ 2012-07-13 7:21 ` Eric Wong
2012-07-13 16:46 ` Hleb Valoshka
1 sibling, 1 reply; 12+ messages in thread
From: Eric Wong @ 2012-07-13 7:21 UTC (permalink / raw)
To: ruby.posix.mq
Hleb Valoshka <375gnu@gmail.com> wrote:
> No, It's on GNU/Linux. On GNU/kFreeBSD I have "Errno::ENOSYS: Function
> not implemented - mq_open" (yes, I've made "kldload mqueuefs).
OK, I've reproduced this, too. Could be an EGLIBC issue...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Add a sleep in alarm test in current Ruby.
2012-07-13 7:21 ` Eric Wong
@ 2012-07-13 16:46 ` Hleb Valoshka
0 siblings, 0 replies; 12+ messages in thread
From: Hleb Valoshka @ 2012-07-13 16:46 UTC (permalink / raw)
To: ruby.posix.mq
On 7/13/12, Eric Wong <normalperson@yhbt.net> wrote:
> Hleb Valoshka <375gnu@gmail.com> wrote:
>> No, It's on GNU/Linux. On GNU/kFreeBSD I have "Errno::ENOSYS: Function
>> not implemented - mq_open" (yes, I've made "kldload mqueuefs).
>
> OK, I've reproduced this, too. Could be an EGLIBC issue...
Or kernel. The following is from irc:
<KiBi> kibi@asdfasdf:~$ sudo ipcs
<KiBi> kernel not configured for shared memory
<KiBi> kernel not configured for semaphores
<KiBi> kernel not configured for message queues
<KiBi> but maybe that's just some missing bits in the kernel.
I dunno what version they run on asdfasdf, but on sid the report from
ipcs is the same.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-07-13 16:47 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-03 20:13 [PATCH 1/3] Fix call to DL::Function.new in tests Hleb Valoshka
2012-07-03 20:13 ` [PATCH 2/3] Add libc names for Debian GNU/kFreeBSD and FreeBSD " Hleb Valoshka
2012-07-03 20:13 ` [PATCH 3/3] Add a sleep in alarm test in current Ruby Hleb Valoshka
2012-07-04 0:20 ` Eric Wong
2012-07-04 0:59 ` Eric Wong
2012-07-04 13:39 ` Hleb Valoshka
2012-07-12 8:03 ` Hleb Valoshka
2012-07-12 8:09 ` Eric Wong
2012-07-12 13:46 ` Hleb Valoshka
2012-07-12 19:46 ` Eric Wong
2012-07-13 7:21 ` Eric Wong
2012-07-13 16:46 ` Hleb Valoshka
Code repositories for project(s) associated with this public inbox
https://yhbt.net/ruby_posix_mq.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).