Skip to content

Commit daf314a

Browse files
committed
Remove usage of IO#nread
IO#wait, a method to obtain the number of bytes readable without blocking, has been removed from io/wait. ruby/io-wait@1decadc When WEBrick is combined with io.wait >= 0.4.0, the following error occurs on shutdown: ERROR NoMethodError: undefined method 'nread' for an instance of IO /(snip)/webrick-1.9.1/lib/webrick/server.rb:178:in 'block in WEBrick::GenericServer#start' WEBrick uses IO#nread to efficiently consume the entire input stream during shutdown. This patch removes the call to IO#nread, and instead repeatedly take a fixed size of 8 bytes each iteration.
1 parent 5584117 commit daf314a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/webrick/server.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ def start(&block)
174174
if svrs[0].include? sp
175175
# swallow shutdown pipe
176176
buf = String.new
177-
nil while String ===
178-
sp.read_nonblock([sp.nread, 8].max, buf, exception: false)
177+
nil while String === sp.read_nonblock(8, buf, exception: false)
179178
break
180179
end
181180
svrs[0].each{|svr|

0 commit comments

Comments
 (0)