From faab3434af2fb3bc7166425e7da61851c46c70bc Mon Sep 17 00:00:00 2001 From: Eugene Pimenov Date: Sat, 7 Mar 2009 17:19:37 +0300 Subject: [PATCH] EventMachine#ssl? method, and skipping ssl tests if it's not available. Signed-off-by: Aman Gupta --- ext/rubymain.cpp | 16 ++++++++++++++++ lib/jeventmachine.rb | 3 +++ lib/pr_eventmachine.rb | 5 +++++ tests/test_httpclient2.rb | 2 +- tests/test_ssl_args.rb | 2 +- tests/test_ssl_methods.rb | 2 +- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ext/rubymain.cpp b/ext/rubymain.cpp index 62e421599..5c0bc1a7a 100644 --- a/ext/rubymain.cpp +++ b/ext/rubymain.cpp @@ -714,6 +714,20 @@ static VALUE t__kqueue_set (VALUE self, VALUE val) } +/******** +t__ssl_p +********/ + +static VALUE t__ssl_p (VALUE self) +{ + #ifdef WITH_SSL + return Qtrue; + #else + return Qfalse; + #endif +} + + /**************** t_send_file_data ****************/ @@ -887,6 +901,8 @@ extern "C" void Init_rubyeventmachine() rb_define_module_function (EmModule, "kqueue=", (VALUE(*)(...))t__kqueue_set, 1); rb_define_module_function (EmModule, "kqueue?", (VALUE(*)(...))t__kqueue_p, 0); + rb_define_module_function (EmModule, "ssl?", (VALUE(*)(...))t__ssl_p, 0); + rb_define_method (EmConnection, "get_outbound_data_size", (VALUE(*)(...))conn_get_outbound_data_size, 0); rb_define_method (EmConnection, "associate_callback_target", (VALUE(*)(...))conn_associate_callback_target, 1); diff --git a/lib/jeventmachine.rb b/lib/jeventmachine.rb index 6d0be3b77..b9c070cd5 100644 --- a/lib/jeventmachine.rb +++ b/lib/jeventmachine.rb @@ -96,6 +96,9 @@ def self.set_comm_inactivity_timeout sig, interval def self.start_tls sig @em.startTls sig end + def self.ssl? + false + end def self.signal_loopbreak @em.signalLoopbreak end diff --git a/lib/pr_eventmachine.rb b/lib/pr_eventmachine.rb index a57e64142..3e8c5804e 100644 --- a/lib/pr_eventmachine.rb +++ b/lib/pr_eventmachine.rb @@ -152,6 +152,11 @@ def set_timer_quantum interval def epoll end + # #ssl? is not implemented for pure-Ruby implementation + def ssl? + false + end + # #set_rlimit_nofile is a no-op in the pure-Ruby implementation. We simply return Ruby's built-in # per-process file-descriptor limit. def set_rlimit_nofile n diff --git a/tests/test_httpclient2.rb b/tests/test_httpclient2.rb index ff630ad30..c14777009 100644 --- a/tests/test_httpclient2.rb +++ b/tests/test_httpclient2.rb @@ -146,7 +146,7 @@ def test_https_get } } assert_equal(200, d.status) - end + end if EM.ssl? diff --git a/tests/test_ssl_args.rb b/tests/test_ssl_args.rb index e562dcf7a..64331abef 100644 --- a/tests/test_ssl_args.rb +++ b/tests/test_ssl_args.rb @@ -65,4 +65,4 @@ def test_tls_params_file_does_exist assert(false, 'should not have raised an exception') end end -end \ No newline at end of file +end if EM.ssl? \ No newline at end of file diff --git a/tests/test_ssl_methods.rb b/tests/test_ssl_methods.rb index 0788caa5e..0cc7488fd 100644 --- a/tests/test_ssl_methods.rb +++ b/tests/test_ssl_methods.rb @@ -47,4 +47,4 @@ def test_ssl_methods assert($client_cert_value.is_a?(String)) end -end \ No newline at end of file +end if EM.ssl? \ No newline at end of file