Skip to content

Commit

Permalink
Add Client#io_ok?, check before Reactor#register (#2432)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Oct 25, 2020
1 parent 9efa3aa commit 6c69e29
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* Adds max_fast_inline as a configuration option for the Server object (#2406)

* Bugfixes
* Fix hang on shutdown in refork (#2442)
* Fix `Bundler::GemNotFound` errors for `nio4r` gem during phased restarts (#2427, #2018)
* Server run thread safety fix (#2435)
* Fire `on_booted` after server starts (#2431, #2212)
* Cleanup daemonization in rc.d script (#2409)
* Fix `Bundler::GemNotFound` errors for `nio4r` gem during phased restarts (#2427)
* Fire `on_booted` after server starts

* Refactor
* Extract req/resp methods to new request.rb from server.rb (#2419)
Expand Down
6 changes: 6 additions & 0 deletions lib/puma/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def initialize(io, env=nil)

def_delegators :@io, :closed?

# Test to see if io meets a bare minimum of functioning, @to_io needs to be
# used for MiniSSL::Socket
def io_ok?
@to_io.is_a?(::BasicSocket) && !closed?
end

# @!attribute [r] inspect
def inspect
"#<Puma::Client:0x#{object_id.to_s(16)} @ready=#{@ready.inspect}>"
Expand Down
5 changes: 4 additions & 1 deletion lib/puma/reactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def select_loop
timed_out.each(&method(:wakeup!))

unless @input.empty?
register(@input.pop) until @input.empty?
until @input.empty?
client = @input.pop
register(client) if client.io_ok?
end
@timeouts.sort_by!(&:timeout_at)
end
end
Expand Down

0 comments on commit 6c69e29

Please sign in to comment.