diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-09-25 20:32:32 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-09-25 20:32:32 +0000 |
commit | 81d66a794338e241e00b9ffd66fc94b80064475d (patch) | |
tree | ac78a134481012c438506a068cdb233a025b8a47 | |
parent | bc4aaf4afdfb42ad5cc5e0729f816fbefb3d338e (diff) | |
download | sleepy_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.c | 6 | ||||
-rw-r--r-- | test/test_epoll.rb | 8 |
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 } |