Project

General

Profile

Actions

Bug #814

closed

NoMethodError: undefined method `read_nonblock' for #<OpenSSL::SSL::SSLSocket:0x1a64f9a0>

Added by tenderlovemaking (Aaron Patterson) about 16 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
1.9.2
Backport:
[ruby-core:20241]

Description

=begin
My patch from #806 broke because OpenSSL::SSL::SSLSocket doesn't implement read_nonblock.

I've attached a patch that implements read_nonblock on OpenSSL::SSL::SSLSocket.

This is a naive patch.
=end


Files

openssl.patch (2.16 KB) openssl.patch SSLSocket patch tenderlovemaking (Aaron Patterson), 12/03/2008 02:00 PM
better.patch (4.64 KB) better.patch better patch with tests. tenderlovemaking (Aaron Patterson), 12/04/2008 09:02 AM
Actions #1

Updated by tenderlovemaking (Aaron Patterson) about 16 years ago

=begin
Here is an even better patch. With tests.
=end

Actions #2

Updated by matz (Yukihiro Matsumoto) about 16 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r20493.
=end

Actions #3

Updated by matz (Yukihiro Matsumoto) about 16 years ago

=begin
Hi,

In message "Re: [ruby-core:20298] Re: [Bug #814] NoMethodError: undefined method `read_nonblock' for #OpenSSL::SSL::SSLSocket:0x1a64f9a0"
on Thu, 4 Dec 2008 16:17:26 +0900, Tanaka Akira writes:

|> File better.patch added
|> Here is an even better patch. With tests.
|
|The buffering mechanism of OpenSSL::SSL::SSLSocket is
|implemented in Ruby level. Your read_nonblock ignore it.

Oops. I just checked in the patch. I am awaiting even better patch
then. ;-)

						matz.

=end

Actions #4

Updated by yugui (Yuki Sonoda) about 16 years ago

  • Status changed from Closed to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)
  • Priority changed from Normal to 5
  • Target version set to 1.9.1 Release Candidate

=begin
I did not merged r20493 into ruby_1_9_1 because it makes Net::HTTP::Proxy related tests fail.

  1. Error:
    test_https_proxy_authentication(HTTPSProxyTest):
    Errno::EAGAIN: Resource temporarily unavailable
    /Users/yugui/src/ruby/mri/test/net/http/test_https_proxy.rb:18:in `block (2 levels) in test_https_proxy_authentication'

  2. Failure:
    test_exit_action(TestSignal) [/Users/yugui/src/ruby/mri/test/ruby/test_signal.rb:52]:
    [ruby-dev:26128].
    Exception raised:
    <#<Timeout::Error: execution expired>>.

  3. Error:
    test_connect(TestWEBrickHTTPProxy):
    Errno::EAGAIN: Resource temporarily unavailable
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:162:in block (2 levels) in test_connect' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in start_httpproxy'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:154:in block in test_connect' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:57:in start_httpserver'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:150:in `test_connect'

  4. Error:
    test_upstream_proxy(TestWEBrickHTTPProxy):
    Errno::EAGAIN: Resource temporarily unavailable
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:267:in block (3 levels) in test_upstream_proxy' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:57:in start_httpserver'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:256:in block (2 levels) in test_upstream_proxy' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in start_httpproxy'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:200:in block in test_upstream_proxy' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in start_httpproxy'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:190:in `test_upstream_proxy'

=end

Actions #5

Updated by oldmoe (Muhammad Ali) about 16 years ago

=begin
I noticed the patch only handled the EWOULDBLOCK exceptions and not EAGAIN.

Wouldn't just adding EAGAIN (and EINTR as well) to the handled exceptions
fix the 3 errors?

Regards

oldmoe

On Sun, Dec 21, 2008 at 5:59 AM, Yuki Sonoda wrote:

Issue #814 has been updated by Yuki Sonoda.

Status changed from Closed to Assigned
Assigned to set to Yukihiro Matsumoto
Priority changed from Normal to High
Target version set to 1.9.1 Release Candidate

I did not merged r20493 into ruby_1_9_1 because it makes Net::HTTP::Proxy
related tests fail.

  1. Error:
    test_https_proxy_authentication(HTTPSProxyTest):
    Errno::EAGAIN: Resource temporarily unavailable
    /Users/yugui/src/ruby/mri/test/net/http/test_https_proxy.rb:18:in `block
    (2 levels) in test_https_proxy_authentication'

  2. Failure:
    test_exit_action(TestSignal)
    [/Users/yugui/src/ruby/mri/test/ruby/test_signal.rb:52]:
    [ruby-dev:26128].
    Exception raised:
    <#<Timeout::Error: execution expired>>.

  3. Error:
    test_connect(TestWEBrickHTTPProxy):
    Errno::EAGAIN: Resource temporarily unavailable
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:162:in block (2 levels) in test_connect' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in start_httpproxy'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:154:in block in test_connect' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:57:in start_httpserver'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:150:in
    `test_connect'

  4. Error:
    test_upstream_proxy(TestWEBrickHTTPProxy):
    Errno::EAGAIN: Resource temporarily unavailable
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:267:in block (3 levels) in test_upstream_proxy' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:57:in start_httpserver'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:256:in block (2 levels) in test_upstream_proxy' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in start_httpproxy'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:200:in block in test_upstream_proxy' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in yield'
    /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in start_server' /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in start_httpproxy'
    /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:190:in
    `test_upstream_proxy'


http://redmine.ruby-lang.org/issues/show/814


http://redmine.ruby-lang.org

I noticed the patch only handled the EWOULDBLOCK exceptions and not EAGAIN.

Wouldn't just adding EAGAIN  (and EINTR as well) to the handled exceptions fix the 3 errors?

Regards

oldmoe

On Sun, Dec 21, 2008 at 5:59 AM, Yuki Sonoda <> wrote:
Issue #814 has been updated by Yuki Sonoda.

Status changed from Closed to Assigned
Assigned to set to Yukihiro Matsumoto
Priority changed from Normal to High
Target version set to 1.9.1 Release Candidate

I did not merged r20493 into ruby_1_9_1 because it makes Net::HTTP::Proxy related tests fail.

 1) Error:
test_https_proxy_authentication(HTTPSProxyTest):
Errno::EAGAIN: Resource temporarily unavailable
   /Users/yugui/src/ruby/mri/test/net/http/test_https_proxy.rb:18:in `block (2 levels) in test_https_proxy_authentication'

 2) Failure:
test_exit_action(TestSignal) [/Users/yugui/src/ruby/mri/test/ruby/test_signal.rb:52]:
[ruby-dev:26128].
Exception raised:
<#<Timeout::Error: execution expired>>.

 3) Error:
test_connect(TestWEBrickHTTPProxy):
Errno::EAGAIN: Resource temporarily unavailable
   /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:162:in `block (2 levels) in test_connect'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `yield'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `start_server'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in `start_httpproxy'
   /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:154:in `block in test_connect'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `yield'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `start_server'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:57:in `start_httpserver'
   /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:150:in `test_connect'

 4) Error:
test_upstream_proxy(TestWEBrickHTTPProxy):
Errno::EAGAIN: Resource temporarily unavailable
   /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:267:in `block (3 levels) in test_upstream_proxy'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `yield'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `start_server'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:57:in `start_httpserver'
   /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:256:in `block (2 levels) in test_upstream_proxy'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `yield'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `start_server'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in `start_httpproxy'
   /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:200:in `block in test_upstream_proxy'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `yield'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:46:in `start_server'
   /Users/yugui/src/ruby/mri/test/webrick/utils.rb:61:in `start_httpproxy'
   /Users/yugui/src/ruby/mri/test/webrick/test_httpproxy.rb:190:in `test_upstream_proxy'


----------------------------------------
http://redmine.ruby-lang.org/issues/show/814

----------------------------------------
http://redmine.ruby-lang.org


=end

Actions #6

Updated by yugui (Yuki Sonoda) about 16 years ago

=begin
The error I reported is because I did not apply r20443.

And we (matz, akr and I) decided to apply neighter r20443 nor r20493 to 1.9.1

=end

Actions #7

Updated by yugui (Yuki Sonoda) almost 16 years ago

  • Status changed from Assigned to Open
  • Assignee deleted (matz (Yukihiro Matsumoto))
  • Priority changed from 5 to Normal
  • Target version changed from 1.9.1 Release Candidate to 1.9.2

=begin

=end

Actions #8

Updated by shyouhei (Shyouhei Urabe) almost 16 years ago

  • Status changed from Open to Closed
  • Assignee set to yugui (Yuki Sonoda)
  • ruby -v set to 1.9.2

=begin

=end

Actions #9

Updated by bascule (Tony Arcieri) almost 16 years ago

=begin
For the record, I don't think either of these patches addresses the requirements of non-blocking OpenSSL.

I've created a gem that "monkeypatches" non-blocking SSL support into 1.8.6+ and 1.9.1.

http://github.com/tarcieri/openssl-nonblock

This addresses the full requirements of non-blocking SSL and has been used in real-world applications within a nonblocking event framework.

The requirements addressed by this gem that are not addressed by either of the previous patches:

  • Non-blocking counterparts are provided to ALL OpenSSL::SSL::SSLSocket methods
  • Separate exceptions are provided for when a given operation requires the socket to be in the readable or writable state, regardless of what operation was requested. A read request may require the socket to be writable to continue, or vice versa, due to the requirements of SSL (e.g. session renegotiation)

If it's agreed that my gem fully addresses the requirements of non-blocking OpenSSL, I can easily put together a patch for incorporation into 1.9.2.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0