From 207f50b31a41071d3154c2f752967e50ff056488 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 2 Jan 2017 00:23:36 +0000 Subject: unify rb_gc() handling for out-of-FD conditions This should hopefully simplify logic a bit and avoid expensive access to errno. --- ext/sleepy_penguin/eventfd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'ext/sleepy_penguin/eventfd.c') diff --git a/ext/sleepy_penguin/eventfd.c b/ext/sleepy_penguin/eventfd.c index 4f95b0d..4804150 100644 --- a/ext/sleepy_penguin/eventfd.c +++ b/ext/sleepy_penguin/eventfd.c @@ -31,10 +31,8 @@ static VALUE s_new(int argc, VALUE *argv, VALUE klass) fd = eventfd(initval, flags); if (fd < 0) { - if (errno == EMFILE || errno == ENFILE || errno == ENOMEM) { - rb_gc(); + if (rb_sp_gc_for_fd(errno)) fd = eventfd(initval, flags); - } if (fd < 0) rb_sys_fail("eventfd"); } -- cgit v1.2.3-24-ge0c7