Project

General

Profile

Actions

Bug #11121

closed

openssl ext does not handle EWOULDBLOCK

Added by pep (Pep Turró Mauri) almost 9 years ago. Updated almost 9 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
[ruby-core:69077]

Description

On Windows, non-blocking IO on sockets seems to return EWOULDBLOCK instead of EAGAIN. The openssl ruby library only handles EAGAIN, which results in EWOULDBLOCK being raised to the caller.

This was noticed while using httpclient to send a POST request to an https server via an http proxy on a Windows system:

A non-blocking socket operation could not be completed immediately. (Errno::EWOULDBLOCK)
  C:/Ruby193/lib/ruby/1.9.1/openssl/buffering.rb:53:in `sysread'
  C:/Ruby193/lib/ruby/1.9.1/openssl/buffering.rb:53:in `sysread'
  C:/Ruby193/lib/ruby/1.9.1/openssl/buffering.rb:53:in `fill_rbuff'
  C:/Ruby193/lib/ruby/1.9.1/openssl/buffering.rb:200:in `gets'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:356:in `gets'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:876:in `block in parse_header'
  C:/Ruby193/lib/ruby/1.9.1/timeout.rb:55:in `timeout'
  C:/Ruby193/lib/ruby/1.9.1/timeout.rb:100:in `timeout'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:872:in `parse_header'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:833:in `connect_ssl_proxy'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:753:in `block in connect'
  C:/Ruby193/lib/ruby/1.9.1/timeout.rb:55:in `timeout'
  C:/Ruby193/lib/ruby/1.9.1/timeout.rb:100:in `timeout'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:746:in `connect'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:612:in `query'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:164:in `query'
  ...

We could only reproduce it in this environment so far (old version, invoking this particular call, over a proxy) but I believe the same problem can appear at any time with current versions.

An example from current trunk (ext/openssl/lib/openssl/buffering.rb):

  def fill_rbuff
    begin
      @rbuffer << self.sysread(BLOCK_SIZE)
    rescue Errno::EAGAIN
      retry
    rescue EOFError
      @eof = true
    end
  end

there are multiple references in that file, e.g.
https://github.com/ruby/ruby/blob/trunk/ext/openssl/lib/openssl/buffering.rb#L62
https://github.com/ruby/ruby/blob/trunk/ext/openssl/lib/openssl/buffering.rb#L327

Updated by normalperson (Eric Wong) almost 9 years ago

Which version of OpenSSL is this? I wonder if OpenSSL is not returning
SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE properly when it sees
EWOULDBLOCK.

Assuming OpenSSL returns SSL_ERROR_WANT_* properly, I'm not seeing
where we can even raise EAGAIN/EWOULDBLOCK from ext/openssl/ossl_ssl.c

Updated by hsbt (Hiroshi SHIBATA) almost 9 years ago

  • Status changed from Open to Feedback

Is there this issue on Ruby 2.1 or 2.2? Ruby 1.9.3 is EOL.

Updated by pep (Pep Turró Mauri) almost 9 years ago

Thanks for the feedback and apologies for the delay here - it took a while to do further testing and confirming with the 3rd party who originally hit the problem.

We couldn't reproduce this with more recent versions. 3rd party confirmed that they can't reproduce with ruby 2.1.6p336.

They hit some unrelated problems installing 2.2 but I think at this point it's safe to say the problem doesn't reproduce in current versions and can be closed.

Updated by zzak (zzak _) almost 9 years ago

  • Status changed from Feedback to Third Party's Issue

Thanks for following up!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0