From e627ab1c9836d2c8e53a164fd597a1731ec0af18 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Mon, 15 Jun 2009 23:44:12 -0700 Subject: [PATCH] Raise EM::Unsupported on EM.epoll/kqueue= on unsupported platforms --- ext/rubymain.cpp | 10 ++++++---- tests/test_epoll.rb | 2 -- tests/test_next_tick.rb | 2 -- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ext/rubymain.cpp b/ext/rubymain.cpp index 892f0fdae..f08fe14ca 100644 --- a/ext/rubymain.cpp +++ b/ext/rubymain.cpp @@ -34,6 +34,7 @@ static VALUE EmConnection; static VALUE EM_eUnknownTimerFired; static VALUE EM_eConnectionNotBound; +static VALUE EM_eUnsupported; static VALUE Intern_at_signature; static VALUE Intern_at_timers; @@ -723,7 +724,7 @@ t__epoll static VALUE t__epoll (VALUE self) { if (t__epoll_p(self) == Qfalse) - return Qfalse; + rb_raise (EM_eUnsupported, "epoll is not supported on this platform"); evma_set_epoll (1); return Qtrue; @@ -736,7 +737,7 @@ t__epoll_set static VALUE t__epoll_set (VALUE self, VALUE val) { if (t__epoll_p(self) == Qfalse) - return Qfalse; + rb_raise (EM_eUnsupported, "epoll is not supported on this platform"); evma_set_epoll (val == Qtrue ? 1 : 0); return val; @@ -763,7 +764,7 @@ t__kqueue static VALUE t__kqueue (VALUE self) { if (t__kqueue_p(self) == Qfalse) - return Qfalse; + rb_raise (EM_eUnsupported, "kqueue is not supported on this platform"); evma_set_kqueue (1); return Qtrue; @@ -776,7 +777,7 @@ t__kqueue_set static VALUE t__kqueue_set (VALUE self, VALUE val) { if (t__kqueue_p(self) == Qfalse) - return Qfalse; + rb_raise (EM_eUnsupported, "kqueue is not supported on this platform"); evma_set_kqueue (val == Qtrue ? 1 : 0); return val; @@ -959,6 +960,7 @@ extern "C" void Init_rubyeventmachine() rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", rb_eException); EM_eConnectionNotBound = rb_define_class_under (EmModule, "ConnectionNotBound", rb_eRuntimeError); EM_eUnknownTimerFired = rb_define_class_under (EmModule, "UnknownTimerFired", rb_eRuntimeError); + EM_eUnsupported = rb_define_class_under (EmModule, "Unsupported", rb_eRuntimeError); rb_define_module_function (EmModule, "initialize_event_machine", (VALUE(*)(...))t_initialize_event_machine, 0); rb_define_module_function (EmModule, "run_machine", (VALUE(*)(...))t_run_machine_without_threads, 0); diff --git a/tests/test_epoll.rb b/tests/test_epoll.rb index 9ec047bce..1c9aae11f 100644 --- a/tests/test_epoll.rb +++ b/tests/test_epoll.rb @@ -94,7 +94,6 @@ def test_defer n = 0 work_proc = proc {n += 1} callback_proc = proc {EM.stop} - EM.epoll EM.run { EM.defer work_proc, callback_proc } @@ -120,7 +119,6 @@ def receive_data dgm def test_datagrams $in = $out = "" - EM.epoll EM.run { EM.open_datagram_socket "127.0.0.1", 9500, TestDatagramServer EM.open_datagram_socket "127.0.0.1", 0, TestDatagramClient diff --git a/tests/test_next_tick.rb b/tests/test_next_tick.rb index 6e50e0d6a..42667e9d1 100644 --- a/tests/test_next_tick.rb +++ b/tests/test_next_tick.rb @@ -33,7 +33,6 @@ class TestNextTick < Test::Unit::TestCase def test_tick_arg pr = proc {EM.stop} - EM.epoll EM.run { EM.next_tick pr } @@ -41,7 +40,6 @@ def test_tick_arg end def test_tick_block - EM.epoll EM.run { EM.next_tick {EM.stop} }