class OpenSSL::SSL::SSLServer
OpenSSL
socket helper methods (to make it compatible with Socket
API) and overrides
Attributes
ctx[R]
Public Instance Methods
accept()
click to toggle source
# File lib/polyphony/extensions/openssl.rb, line 120 def accept # when @ctx.servername_cb is set, we use a worker thread to run the # ssl.accept call. We need to do this because: # - We cannot switch fibers inside of the servername_cb proc (see # https://github.com/ruby/openssl/issues/415) # - We don't want to stop the world while we're busy provisioning an ACME # certificate if @use_accept_worker.nil? if (@use_accept_worker = use_accept_worker_thread?) start_accept_worker_thread end end sock, = @svr.accept begin ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx) ssl.sync_close = true if @use_accept_worker @accept_worker_fiber << [ssl, Fiber.current] receive else ssl.accept end ssl rescue Exception => ex if ssl ssl.close else sock.close end raise ex end end
Also aliased as: orig_accept
accept_loop(ignore_errors = true) { |accept| ... }
click to toggle source
# File lib/polyphony/extensions/openssl.rb, line 179 def accept_loop(ignore_errors = true) loop do yield accept rescue SystemCallError, StandardError => e raise e unless ignore_errors end end
close()
click to toggle source
# File lib/polyphony/extensions/openssl.rb, line 174 def close @accept_worker_thread&.kill orig_close end
Also aliased as: orig_close
start_accept_worker_thread()
click to toggle source
# File lib/polyphony/extensions/openssl.rb, line 154 def start_accept_worker_thread fiber = Fiber.current @accept_worker_thread = Thread.new do fiber << Fiber.current loop do socket, peer = receive socket.accept peer << socket rescue => e peer.schedule(e) if fiber end end @accept_worker_fiber = receive end
use_accept_worker_thread?()
click to toggle source
# File lib/polyphony/extensions/openssl.rb, line 169 def use_accept_worker_thread? !!@ctx.servername_cb end