1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Make write_nonblock available under SSL (#1274)

* Stub out write_nonblock with write

* Support (and discard) keywords used

* Handle keywords to read_nonblock as well

* Thing -> think
This commit is contained in:
Evan Phoenix 2017-05-01 09:54:00 -07:00 committed by Nate Berkopec
parent 482ea5a24a
commit 7cd363f799

View file

@ -36,7 +36,9 @@ module Puma
output
end
def read_nonblock(size)
def read_nonblock(size, *_)
# *_ is to deal with keyword args that were added
# at some point (and being used in the wild)
while true
output = engine_read_all
return output if output
@ -77,6 +79,19 @@ module Puma
alias_method :syswrite, :write
alias_method :<<, :write
# This is a temporary fix to deal with websockets code using
# write_nonblock. The problem with implementing it properly
# is that it means we'd have to have the ability to rewind
# an engine because after we write+extract, the socket
# write_nonblock call might raise an exception and later
# code would pass the same data in, but the engine would think
# it had already written the data in. So for the time being
# (and since write blocking is quite rare), go ahead and actually
# block in write_nonblock.
def write_nonblock(data, *_)
write data
end
def flush
@socket.flush
end