about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-04-11 04:17:35 +0000
committerEric Wong <normalperson@yhbt.net>2013-04-12 22:25:04 +0000
commitd4b5c8d7c1abe673915aca8674c5e0b55a0aaffa (patch)
treebf05620b175f6d12f29c80e878cedf954dccaeb1
parent49cb42a42022dffd98fc5b3acdb2dfc7bf5bd156 (diff)
downloadsleepy_penguin-d4b5c8d7c1abe673915aca8674c5e0b55a0aaffa.tar.gz
ENOMEM from syscalls such as inotify_add_watch and epoll_ctl are
from the lack of kernel memory, so even a successful rb_gc() is
unlikely to be able to reap memory taken from those slab caches.
-rw-r--r--ext/sleepy_penguin/epoll.c10
-rw-r--r--ext/sleepy_penguin/inotify.c11
2 files changed, 5 insertions, 16 deletions
diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c
index 82a545f..ed45fbd 100644
--- a/ext/sleepy_penguin/epoll.c
+++ b/ext/sleepy_penguin/epoll.c
@@ -139,14 +139,8 @@ static VALUE epctl(VALUE self, VALUE _op, VALUE io, VALUE events)
         pack_event_data(&event, io);
 
         rv = epoll_ctl(epfd, op, fd, &event);
-        if (rv < 0) {
-                if (errno == ENOMEM) {
-                        rb_gc();
-                        rv = epoll_ctl(epfd, op, fd, &event);
-                }
-                if (rv < 0)
-                        rb_sys_fail("epoll_ctl");
-        }
+        if (rv < 0)
+                rb_sys_fail("epoll_ctl");
 
         return Qnil;
 }
diff --git a/ext/sleepy_penguin/inotify.c b/ext/sleepy_penguin/inotify.c
index f858dc4..4c606a4 100644
--- a/ext/sleepy_penguin/inotify.c
+++ b/ext/sleepy_penguin/inotify.c
@@ -89,14 +89,9 @@ static VALUE add_watch(VALUE self, VALUE path, VALUE vmask)
         uint32_t mask = rb_sp_get_uflags(self, vmask);
         int rc = inotify_add_watch(fd, pathname, mask);
 
-        if (rc == -1) {
-                if (errno == ENOMEM) {
-                        rb_gc();
-                        rc = inotify_add_watch(fd, pathname, mask);
-                }
-                if (rc == -1)
-                        rb_sys_fail("inotify_add_watch");
-        }
+        if (rc == -1)
+                rb_sys_fail("inotify_add_watch");
+
         return UINT2NUM((uint32_t)rc);
 }