Project

General

Profile

Bug #814

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

Added by tenderlovemaking (Aaron Patterson) almost 12 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
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
#1

Updated by tenderlovemaking (Aaron Patterson) almost 12 years ago

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

#2

Updated by matz (Yukihiro Matsumoto) almost 12 years ago

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

=begin
Applied in changeset r20493.
=end

#3

Updated by matz (Yukihiro Matsumoto) almost 12 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 akr@fsij.org 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

#4

Updated by yugui (Yuki Sonoda) almost 12 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:
<#>.

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

#5

Updated by oldmoe (Muhammad Ali) almost 12 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 redmine@ruby-lang.org 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:
<#>.

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?
RegardsoldmoeOn Sun, Dec 21, 2008 at 5:59 AM, Yuki Sonoda <redmine@ruby-lang.org> 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&#39;<br>
<br>
&nbsp;2) Failure:<br>
test_exit_action(TestSignal) [/Users/yugui/src/ruby/mri/test/ruby/test_signal.rb:52]:<br>
[ruby-dev:26128].<br>
Exception raised:<br>
&lt;#&lt;Timeout::Error: execution expired&gt;&gt;.<br>
<br>
&nbsp;3) Error:<br>
test_connect(TestWEBrickHTTPProxy):<br>
Errno::EAGAIN: Resource temporarily unavailable<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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&#39;<br>
&nbsp; &nbsp;/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

#6

Updated by yugui (Yuki Sonoda) almost 12 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

#7

Updated by yugui (Yuki Sonoda) almost 12 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

#8

Updated by shyouhei (Shyouhei Urabe) over 11 years ago

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

=begin

=end

#9

Updated by bascule (Tony Arcieri) over 11 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

#10

Updated by akr (Akira Tanaka) over 11 years ago

=begin
[ruby-core:22539]
=end

Also available in: Atom PDF