mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Be more hostile with sockets that write block. Fixes #449
This commit is contained in:
parent
491cffffda
commit
f8d49e86ab
2 changed files with 9 additions and 2 deletions
|
@ -41,6 +41,10 @@ module Puma
|
||||||
# for the request
|
# for the request
|
||||||
FIRST_DATA_TIMEOUT = 30
|
FIRST_DATA_TIMEOUT = 30
|
||||||
|
|
||||||
|
# How long to wait when getting some write blocking on the socket when
|
||||||
|
# sending data back
|
||||||
|
WRITE_TIMEOUT = 10
|
||||||
|
|
||||||
DATE = "Date".freeze
|
DATE = "Date".freeze
|
||||||
|
|
||||||
SCRIPT_NAME = "SCRIPT_NAME".freeze
|
SCRIPT_NAME = "SCRIPT_NAME".freeze
|
||||||
|
|
|
@ -779,10 +779,13 @@ module Puma
|
||||||
begin
|
begin
|
||||||
n = io.syswrite str
|
n = io.syswrite str
|
||||||
rescue Errno::EAGAIN, Errno::EWOULDBLOCK
|
rescue Errno::EAGAIN, Errno::EWOULDBLOCK
|
||||||
IO.select(nil, [io], nil, 1)
|
if !IO.select(nil, [io], nil, WRITE_TIMEOUT)
|
||||||
|
raise ConnectionError, "Socket timeout writing data"
|
||||||
|
end
|
||||||
|
|
||||||
retry
|
retry
|
||||||
rescue Errno::EPIPE, SystemCallError, IOError
|
rescue Errno::EPIPE, SystemCallError, IOError
|
||||||
return false
|
raise ConnectionError, "Socket timeout writing data"
|
||||||
end
|
end
|
||||||
|
|
||||||
return if n == str.bytesize
|
return if n == str.bytesize
|
||||||
|
|
Loading…
Add table
Reference in a new issue