Skip to content

Commit

Permalink
EventMachine#ssl? method, and skipping ssl tests if it's not available.
Browse files Browse the repository at this point in the history
Signed-off-by: Aman Gupta <aman@tmm1.net>
  • Loading branch information
libc authored and tmm1 committed Mar 17, 2009
1 parent dbe45be commit faab343
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
16 changes: 16 additions & 0 deletions ext/rubymain.cpp
Expand Up @@ -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
****************/
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions lib/jeventmachine.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/pr_eventmachine.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_httpclient2.rb
Expand Up @@ -146,7 +146,7 @@ def test_https_get
}
}
assert_equal(200, d.status)
end
end if EM.ssl?



Expand Down
2 changes: 1 addition & 1 deletion tests/test_ssl_args.rb
Expand Up @@ -65,4 +65,4 @@ def test_tls_params_file_does_exist
assert(false, 'should not have raised an exception')
end
end
end
end if EM.ssl?
2 changes: 1 addition & 1 deletion tests/test_ssl_methods.rb
Expand Up @@ -47,4 +47,4 @@ def test_ssl_methods
assert($client_cert_value.is_a?(String))
end

end
end if EM.ssl?

0 comments on commit faab343

Please sign in to comment.