about summary refs log tree commit homepage
path: root/ext/sleepy_penguin/eventfd.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-03-01 19:50:27 +0000
committerEric Wong <normalperson@yhbt.net>2013-03-01 19:50:27 +0000
commit2f5c82c26aeaf3536deace3521097d3e9eaefc20 (patch)
treefe3234161ee0156ccd1ca137ad932699303b298e /ext/sleepy_penguin/eventfd.c
parentc217412e59dedf0fa98069815c395339007ede6b (diff)
downloadsleepy_penguin-2f5c82c26aeaf3536deace3521097d3e9eaefc20.tar.gz
The file descriptor may be closed while GVL is released,
so we must reload the descriptor before and after calling
rb_io_wait_*able functions.

We reload before calling rb_io_wait_*able because the GVL was
released for the function call (read/write) which triggered
EAGAIN.

We reload after calling rb_io_wait_*able because
rb_io_wait_*able releases the GVL, too.
Diffstat (limited to 'ext/sleepy_penguin/eventfd.c')
-rw-r--r--ext/sleepy_penguin/eventfd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/sleepy_penguin/eventfd.c b/ext/sleepy_penguin/eventfd.c
index 9d75c91..3ba8397 100644
--- a/ext/sleepy_penguin/eventfd.c
+++ b/ext/sleepy_penguin/eventfd.c
@@ -91,7 +91,7 @@ retry:
         if (w == -1) {
                 if (errno == EAGAIN && RTEST(nonblock))
                         return Qfalse;
-                if (rb_io_wait_writable(x.fd))
+                if (rb_sp_wait(rb_io_wait_writable, self, &x.fd))
                         goto retry;
                 rb_sys_fail("write(eventfd)");
         }
@@ -127,7 +127,7 @@ retry:
         if (w == -1) {
                 if (errno == EAGAIN && RTEST(nonblock))
                         return Qnil;
-                if (rb_io_wait_readable(x.fd = rb_sp_fileno(self)))
+                if (rb_sp_wait(rb_io_wait_readable, self, &x.fd))
                         goto retry;
                 rb_sys_fail("read(eventfd)");
         }