about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-09-25 20:32:32 +0000
committerEric Wong <normalperson@yhbt.net>2010-09-25 20:32:32 +0000
commit81d66a794338e241e00b9ffd66fc94b80064475d (patch)
treeac78a134481012c438506a068cdb233a025b8a47
parentbc4aaf4afdfb42ad5cc5e0729f816fbefb3d338e (diff)
downloadsleepy_penguin-81d66a794338e241e00b9ffd66fc94b80064475d.tar.gz
We don't have to emulate the C API exactly, and it
makes life saner/easier for our users.
-rw-r--r--ext/sleepy_penguin/epoll.c6
-rw-r--r--test/test_epoll.rb8
2 files changed, 11 insertions, 3 deletions
diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c
index da96bd7..d4610d8 100644
--- a/ext/sleepy_penguin/epoll.c
+++ b/ext/sleepy_penguin/epoll.c
@@ -362,9 +362,9 @@ static VALUE add(VALUE self, VALUE io, VALUE flags)
 }
 
 /* adds +io+ object the +self+ with +flags+ */
-static VALUE del(VALUE self, VALUE io, VALUE flags)
+static VALUE del(VALUE self, VALUE io)
 {
-        return ctl(self, io, flags, EPOLL_CTL_DEL);
+        return ctl(self, io, INT2NUM(0), EPOLL_CTL_DEL);
 }
 
 static VALUE mod(VALUE self, VALUE io, VALUE flags)
@@ -447,7 +447,7 @@ void sleepy_penguin_init_epoll(void)
         rb_define_method(cEpoll, "closed?", epclosed, 0);
         rb_define_method(cEpoll, "add", add, 2);
         rb_define_method(cEpoll, "mod", mod, 2);
-        rb_define_method(cEpoll, "del", del, 2);
+        rb_define_method(cEpoll, "del", del, 1);
         rb_define_method(cEpoll, "set", set, 2);
         rb_define_method(cEpoll, "wait", epwait, -1);
         rb_define_const(cEpoll, "CLOEXEC", INT2NUM(EPOLL_CLOEXEC));
diff --git a/test/test_epoll.rb b/test/test_epoll.rb
index a2f739f..ea9bddf 100644
--- a/test/test_epoll.rb
+++ b/test/test_epoll.rb
@@ -193,6 +193,14 @@ class TestEpoll < Test::Unit::TestCase
     assert(diff >= 0.075, "#{diff} < 0.100s")
   end
 
+  def test_del
+    assert_raises(Errno::ENOENT) { @ep.del(@rd) }
+    assert_nothing_raised do
+      @ep.add(@rd, Epoll::IN)
+      @ep.del(@rd)
+    end
+  end
+
   def test_wait_read
     @ep.add(@rd, Epoll::IN)
     assert_equal 0, @ep.wait(nil, 0) { |flags,obj| assert false }