[ruby-core:69634] [Ruby trunk - Bug #11121] [Third Party's Issue] openssl ext does not handle EWOULDBLOCK

From: e@...
Date: 2015-06-17 15:41:04 UTC
List: ruby-core #69634
Issue #11121 has been updated by Zachary Scott.

Status changed from Feedback to Third Party's Issue

Thanks for following up!

----------------------------------------
Bug #11121: openssl ext does not handle EWOULDBLOCK
https://bugs.ruby-lang.org/issues/11121#change-52987

* Author: Pep Turr=C3=B3 Mauri
* Status: Third Party's Issue
* Priority: Normal
* Assignee:=20
* ruby -v: ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
On Windows, non-blocking IO on sockets seems to return EWOULDBLOCK instead =
of EAGAIN. The openssl ruby library only handles EAGAIN, which results in E=
WOULDBLOCK 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/ses=
sion.rb:356:in `gets'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/ses=
sion.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/ses=
sion.rb:872:in `parse_header'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/ses=
sion.rb:833:in `connect_ssl_proxy'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/ses=
sion.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/ses=
sion.rb:746:in `connect'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/ses=
sion.rb:612:in `query'
  C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpclient-2.6.0.1/lib/httpclient/ses=
sion.rb:164:in `query'
  ...
~~~

We could only reproduce it in this environment so far (old version, invokin=
g this particular call, over a proxy) but I believe the same problem can ap=
pear 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 =3D 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




--=20
https://bugs.ruby-lang.org/

In This Thread

Prev Next