From ff020c21f772debbb1a1b247b11325c747288fcb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 19 May 2011 22:43:18 +0000 Subject: better handle cross-thread close under Ruby 1.9.3 We don't want to operate on improper FDs in multithreaded environment. This affects MRI despite the GVL since file descriptors are usually allocated without the GVL held (open()/accept()). --- ext/sleepy_penguin/eventfd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ext/sleepy_penguin/eventfd.c') diff --git a/ext/sleepy_penguin/eventfd.c b/ext/sleepy_penguin/eventfd.c index 4da5e45..9d75c91 100644 --- a/ext/sleepy_penguin/eventfd.c +++ b/ext/sleepy_penguin/eventfd.c @@ -87,7 +87,7 @@ static VALUE incr(int argc, VALUE *argv, VALUE self) RTEST(nonblock) ? rb_sp_set_nonblock(x.fd) : blocking_io_prepare(x.fd); x.val = (uint64_t)NUM2ULL(value); retry: - w = (ssize_t)rb_sp_io_region(efd_write, &x); + w = (ssize_t)rb_sp_fd_region(efd_write, &x, x.fd); if (w == -1) { if (errno == EAGAIN && RTEST(nonblock)) return Qfalse; @@ -123,11 +123,11 @@ static VALUE getvalue(int argc, VALUE *argv, VALUE self) x.fd = rb_sp_fileno(self); RTEST(nonblock) ? rb_sp_set_nonblock(x.fd) : blocking_io_prepare(x.fd); retry: - w = (ssize_t)rb_sp_io_region(efd_read, &x); + w = (ssize_t)rb_sp_fd_region(efd_read, &x, x.fd); if (w == -1) { if (errno == EAGAIN && RTEST(nonblock)) return Qnil; - if (rb_io_wait_readable(x.fd)) + if (rb_io_wait_readable(x.fd = rb_sp_fileno(self))) goto retry; rb_sys_fail("read(eventfd)"); } -- cgit v1.2.3-24-ge0c7