Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch
Puma::MiniSSL::Socket#read_nonblock
to be non-blocking when u…
…sing Capybaras Puma server registration - Fix Issue #2227
- Loading branch information
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module Puma | ||
module MiniSSL | ||
class Socket | ||
def read_nonblock(size, *_) | ||
loop do | ||
output = engine_read_all | ||
return output if output | ||
|
||
data = @socket.read_nonblock(size, exception: false) | ||
raise IO::EAGAINWaitReadable if %i[wait_readable wait_writable].include? data | ||
return nil if data.nil? | ||
|
||
@engine.inject(data) | ||
output = engine_read_all | ||
|
||
return output if output | ||
|
||
while (neg_data = @engine.extract) | ||
@socket.write neg_data | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters