summaryrefslogtreecommitdiff
path: root/ext/openssl
AgeCommit message (Collapse)Author
2015-04-12connect_nonblock supports "exception: false"normal
This is for consistency with accept_nonblock arguments and gives a minor speedup from avoiding exceptions. [ruby-core:68838] [Feature #11024] * ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock): support `exception: false' * (get_no_exception): move function location * ext/socket/socket.c (sock_connect_nonblock): support `exception: false' * test/openssl/test_pair.rb (test_connect_accept_nonblock_no_exception): test `exception: false' on connect, rename from `test_accept_nonblock_no_exception' * test/socket/test_nonblock.rb (test_connect_nonblock_no_exception): new test Benchmark results: default 0.050000 0.100000 0.150000 ( 0.151307) exception: false 0.030000 0.080000 0.110000 ( 0.108840) ----------------------------8<----------------------- require 'socket' require 'benchmark' require 'io/wait' require 'tmpdir' host = '127.0.0.1' serv = TCPServer.new(host, 0) # UNIX sockets may not hit EINPROGRESS nr = 5000 # few iterations to avoid running out of ports addr = serv.getsockname pid = fork do begin serv.accept.close rescue => e warn "#$$: #{e.message} (#{e.class})" end while true end at_exit { Process.kill(:TERM, pid) } serv.close Benchmark.bmbm do |x| x.report("default") do nr.times do s = Socket.new(:INET, :STREAM) s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1) begin s.connect_nonblock(addr) rescue IO::WaitWritable s.wait_writable end s.close end end x.report("exception: false") do nr.times do s = Socket.new(:INET, :STREAM) s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1) case s.connect_nonblock(addr, exception: false) when :wait_writable s.wait_writable end s.close end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12accept_nonblock: favor rb_hash_lookup2 to avoid Hash#defaultnormal
* ext/socket/init.c (rsock_s_accept_nonblock): use rb_hash_lookup2 * ext/openssl/ossl_ssl.c (get_no_exception): new function (ossl_ssl_accept_nonblock): use get_no_exception (ossl_ssl_read_internal): ditto (ossl_ssl_write_nonblock): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12ext/openssl/ossl_ssl.c: predefine wait_*able symbolsnormal
This leads to a size reduction in openssl.so and reduces the chance of bugs due to typos. text data bss dec hex before: 333022 13164 3312 349498 5553a after: 332790 13164 3232 349186 55402 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12accept_nonblock supports "exception: false"normal
This is analogous to functionality found in IO#read_nonblock and IO#wait_nonblock. Raising exceptions for common failures on non-blocking servers is expensive and makes $DEBUG too noisy. Benchmark results: user system total real default 2.790000 0.870000 3.660000 ( 3.671597) exception: false 1.120000 0.800000 1.920000 ( 1.922032) exception: false (cached arg) 0.820000 0.770000 1.590000 ( 1.589267) --------------------- benchmark script ------------------------ require 'socket' require 'benchmark' require 'tmpdir' nr = 1000000 Dir.mktmpdir('nb_bench') do |path| sock_path = "#{path}/test.sock" s = UNIXServer.new(sock_path) Benchmark.bmbm do |x| x.report("default") do nr.times do begin s.accept_nonblock rescue IO::WaitReadable end end end x.report("exception: false") do nr.times do begin s.accept_nonblock(exception: false) rescue IO::WaitReadable abort "should not raise" end end end x.report("exception: false (cached arg)") do arg = { exception: false } nr.times do begin s.accept_nonblock(arg) rescue IO::WaitReadable abort "should not raise" end end end end end * ext/socket/init.c (rsock_s_accept_nonblock): support exception: false [ruby-core:66385] [Feature #10532] * ext/socket/init.c (rsock_init_socket_init): define new symbols * ext/socket/rubysocket.h: adjust prototype * ext/socket/socket.c (sock_accept_nonblock): support exception: false * ext/openssl/ossl_ssl.c (ossl_ssl_accept_nonblock): ditto * ext/socket/socket.c (Init_socket): adjust accept_nonblock definition * ext/openssl/ossl_ssl.c (Init_ossl_ssl): ditto * ext/socket/tcpserver.c (rsock_init_tcpserver): ditto * ext/socket/unixserver.c (rsock_init_unixserver): ditto * ext/socket/tcpserver.c (tcp_accept_nonblock): adjust rsock_s_accept_nonblock call * ext/socket/unixserver.c (unix_accept_nonblock): ditto * ext/openssl/ossl_ssl.c (ossl_start_ssl): support no_exception * ext/openssl/ossl_ssl.c (ossl_ssl_connect): adjust ossl_start_ssl call * ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock): ditto * ext/openssl/ossl_ssl.c (ossl_ssl_accept): ditto * test/socket/test_nonblock.rb (test_accept_nonblock): test for "exception :false" * test/socket/test_tcp.rb (test_accept_nonblock): new test * test/socket/test_unix.rb (test_accept_nonblock): ditto * test/openssl/test_pair.rb (test_accept_nonblock_no_exception): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21ossl_bn.c: [DOC] expand rdocs [ci skip]nobu
* ext/openssl/ossl_bn.c: [DOC] expand rdocs as RDoc does not expand C-preprocessor macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21ossl_asn1.c: fix docnobu
* ext/openssl/ossl_asn1.c (ossl_asn1obj_get_oid): [DOC] fix notation, an instance method but not a class method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21[DOC] Backport ruby/openssl@86eb721 [ci skip]zzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16use rb_funcallvnobu
* use rb_funcallv() for no arguments call instead of variadic rb_funcall(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-12openssl: check RAND_edg to support libresslnobu
* ext/openssl/extconf.rb: check RAND_edg to support libressl. * ext/openssl/ossl_rand.c (ossl_rand_egd): define only if RAND_edg is available. [Fix GH-829] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03* ext/openssl/ossl.h: avoid to build failure of Windows environment.hsbt
* ext/openssl/ossl_ssl_session.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03* ext/openssl/ossl.h: Make `SSL_SESSION_cmp` use `CRYPTO_memcmp`hsbt
[fix GH-591] Patch by @PiPeep * ext/openssl/ossl_ssl_session.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23ossl_cipher.c: workaround of OpenSSL APInobu
* ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge data gradually not to exceed INT_MAX. workaround of OpenSSL API limitation. [ruby-core:67043] [Bug #10633] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-19Update dependencies.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-13ossl_x509store.c: typed datanobu
* ext/openssl/ossl_x509store.c (ossl_x509stctx_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-13ossl_x509store.c: typed datanobu
* ext/openssl/ossl_x509store.c (ossl_x509store_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_x509revoked.c: typed datanobu
* ext/openssl/ossl_x509revoked.c (ossl_x509rev_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_x509req.c: typed datanobu
* ext/openssl/ossl_x509req.c (ossl_x509req_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_x509name.c: typed datanobu
* ext/openssl/ossl_x509name.c (ossl_x509name_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_x509ext.c: typed datanobu
* ext/openssl/ossl_x509ext.c (ossl_x509extfactory_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_x509ext.c: typed datanobu
* ext/openssl/ossl_x509ext.c (ossl_x509ext_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_x509crl.c: typed datanobu
* ext/openssl/ossl_x509crl.c (ossl_x509crl_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_x509cert.c: typed datanobu
* ext/openssl/ossl_x509cert.c (ossl_x509_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_x509attr.c: typed datanobu
* ext/openssl/ossl_x509attr.c (ossl_x509attr_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_pkey_ec.c: typed datanobu
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_pkey_ec.c: typed datanobu
* ext/openssl/ossl_pkey_ec.c (ossl_ec_group_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_pkey.c: typed datanobu
* ext/openssl/ossl_pkey.c (ossl_evp_pkey_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_pkcs7.c: typed datanobu
* ext/openssl/ossl_pkcs7.c (ossl_pkcs7_recip_info_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_pkcs7.c: typed datanobu
* ext/openssl/ossl_pkcs7.c (ossl_pkcs7_signer_info_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_pkcs7.c: typed datanobu
* ext/openssl/ossl_pkcs7.c (ossl_pkcs7_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_pkcs12.c: typed datanobu
* ext/openssl/ossl_pkcs12.c (ossl_pkcs12_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ssl.c: typed datanobu
* ext/openssl/ossl_ssl.c (ossl_ssl_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ssl.c: typed datanobu
* ext/openssl/ossl_ssl.c (ossl_sslctx_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ssl_session.c: typed datanobu
* ext/openssl/ossl_ssl_session.c (ossl_ssl_session_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ocsp.c: typed datanobu
* ext/openssl/ossl_ocsp.c (ossl_ocsp_certid_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ocsp.c: typed datanobu
* ext/openssl/ossl_ocsp.c (ossl_ocsp_basicresp_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ocsp.c: typed datanobu
* ext/openssl/ossl_ocsp.c (ossl_ocsp_response_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ocsp.c: typed datanobu
* ext/openssl/ossl_ocsp.c (ossl_ocsp_request_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ns_spki.c: typed datanobu
* ext/openssl/ossl_ns_spki.c (ossl_netscape_spki_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_hmac.c: typed datanobu
* ext/openssl/ossl_hmac.c (ossl_hmac_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_engine.c: typed datanobu
* ext/openssl/ossl_engine.c (ossl_engine_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_digest.c: typed datanobu
* ext/openssl/ossl_digest.c (ossl_digest_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12ossl_ssl.h: accessor macrosnobu
* ext/openssl/ossl_ssl.c (GetSSLCTX): accessor macro. * ext/openssl/ossl_ssl.h (GetSSL): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01use 0 for reservednobu
use 0 for rb_data_type_t::reserved instead of NULL, since its type may be changed in the future and possibly not a pointer type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-21Update dependency.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-20* ext/openssl/lib/openssl/x509.rbusa
(OpenSSL::X509::Name::RFC2253DN::StringChar): get rid of a false positive assertion in ripper's test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15Mark auogenerated part.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* common.mk: Remove comments in Dependency lines.akr
Notified by usa. * enc/depend: Ditto. * ext/**/depend: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* tool/update-deps: Extend to fix dependencies.akr
* common.mk: Dependencies updated by tool/update-deps. * enc/depend: Ditto. * ext/**/depend: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-22* ext/openssl/lib/openssl/ssl.rb (DEFAULT_PARAMS): overridenagachika
options even if OpenSSL::SSL::OP_NO_SSLv3 is not defined. this is pointed out by Stephen Touset. [ruby-core:65711] [Bug #9424] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-04openssl: typed datanobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e