Skip to content

Commit

Permalink
Combine PR's #1437, 44, & 63 (#1464)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg authored and nateberkopec committed Nov 20, 2017
1 parent 998882e commit 7165775
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -13,6 +13,6 @@ gem "jruby-openssl", :platform => "jruby"

gem "rubocop", "~> 0.49.1"

if %w(2.2.8 2.3.4 2.4.1).include? RUBY_VERSION
if %w(2.2.7 2.2.8 2.3.4 2.4.1).include? RUBY_VERSION
gem "stopgap_13632", "~> 1.0", :platforms => ["mri", "mingw", "x64_mingw"]
end
9 changes: 6 additions & 3 deletions README.md
Expand Up @@ -217,11 +217,14 @@ Some platforms do not support all Puma features.

## Known Bugs

For MRI versions 2.2.7, 2.3.4 and 2.4.1, you may see ```stream closed in another thread (IOError)```. It may be caused by a [Ruby bug](https://bugs.ruby-lang.org/issues/13632). It can be fixed with the gem https://rubygems.org/gems/stopgap_13632:
For MRI versions 2.2.7, 2.2.8, 2.3.4 and 2.4.1, you may see ```stream closed in another thread (IOError)```. It may be caused by a [Ruby bug](https://bugs.ruby-lang.org/issues/13632). It can be fixed with the gem https://rubygems.org/gems/stopgap_13632:

```ruby
if %w(2.2.7 2.3.4 2.4.1).include? RUBY_VERSION
gem "stopgap_13632", "~> 1.0", :platforms => ["mri", "mingw", "x64_mingw"]
if %w(2.2.7 2.2.8 2.3.4 2.4.1).include? RUBY_VERSION
begin
require 'stopgap_13632'
rescue LoadError
end
end
```

Expand Down
2 changes: 1 addition & 1 deletion lib/puma/cluster.rb
Expand Up @@ -24,7 +24,7 @@ def stop_workers
@workers.each { |x| x.term }

begin
Process.waitall
@workers.each { |w| Process.waitpid(w.pid) }
rescue Interrupt
log "! Cancelled waiting for workers"
end
Expand Down
30 changes: 18 additions & 12 deletions lib/puma/minissl.rb
@@ -1,3 +1,8 @@
begin
require 'io/wait'
rescue LoadError
end

module Puma
module MiniSSL
class Socket
Expand Down Expand Up @@ -43,19 +48,20 @@ def read_nonblock(size, *_)
output = engine_read_all
return output if output

if /mswin|mingw/ !~ RUBY_PLATFORM
data = @socket.read_nonblock(size)
else
begin
data = @socket.read_nonblock(size)
rescue IO::WaitReadable
IO.select([@socket.to_io])
retry
rescue IO::WaitWritable
IO.select(nil, [@socket.to_io])
retry
begin
data = @socket.read_nonblock(size, exception: false)
if data == :wait_readable || data == :wait_writable
if @socket.to_io.respond_to?(data)
@socket.to_io.__send__(data)
elsif data == :wait_readable
IO.select([@socket.to_io])
else
IO.select(nil, [@socket.to_io])
end
else
break
end
end
end while true

@engine.inject(data)
output = engine_read_all
Expand Down
8 changes: 5 additions & 3 deletions test/helper.rb
@@ -1,9 +1,11 @@
# Copyright (c) 2011 Evan Phoenix
# Copyright (c) 2005 Zed A. Shaw

begin
require 'stopgap_13632' if %w(2.2.7 2.3.4 2.4.1).include? RUBY_VERSION
rescue LoadError
if %w(2.2.7 2.2.8 2.3.4 2.4.1).include? RUBY_VERSION
begin
require 'stopgap_13632'
rescue LoadError
end
end

begin
Expand Down

0 comments on commit 7165775

Please sign in to comment.