[ruby-cvs:67353] normal:r60172 (trunk): webrick: do not hang acceptor on slow TLS connections

normal at ruby-lang.org normal at ruby-lang.org
Fri Oct 13 03:50:07 JST 2017

normal	2017-10-13 03:50:07 +0900 (Fri, 13 Oct 2017)

  New Revision: 60172


    webrick: do not hang acceptor on slow TLS connections
    OpenSSL::SSL::SSLSocket#accept may block indefinitely on clients
    which negotiate the TCP connection, but fail (or are slow) to
    negotiate the subsequent TLS handshake.  This prevents the
    multi-threaded WEBrick server from accepting other connections.
    Since the TLS handshake (via OpenSSL::SSL::SSLSocket#accept)
    consists of normal read/write traffic over TCP, handle it in the
    per-client thread, instead.
    Furthermore, using non-blocking accept() is useful for non-TLS
    sockets anyways because spurious wakeups are possible from
    * lib/webrick/server.rb (accept_client): use TCPServer#accept_nonblock
      and remove OpenSSL::SSL::SSLSocket#accept call
    * lib/webrick/server.rb (start_thread): call OpenSSL::SSL::SSLSocket#accept
    * test/webrick/test_ssl_server.rb (test_slow_connect): new test
      [ruby-core:83221] [Bug #14005]

  Modified files:

More information about the ruby-cvs mailing list