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
|
||||
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
|
||||
|
||||
SCRIPT_NAME = "SCRIPT_NAME".freeze
|
||||
|
|
|
@ -779,10 +779,13 @@ module Puma
|
|||
begin
|
||||
n = io.syswrite str
|
||||
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
|
||||
rescue Errno::EPIPE, SystemCallError, IOError
|
||||
return false
|
||||
raise ConnectionError, "Socket timeout writing data"
|
||||
end
|
||||
|
||||
return if n == str.bytesize
|
||||
|
|
Loading…
Reference in a new issue