From 4551c8ad4d63d4031c618f76d39532b39e88f9be Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 27 Apr 2012 14:42:38 -0700 Subject: [PATCH] stream_input: call shutdown(2) if a client EOFs on us In case the Rack app forks before a client upload is complete, shutdown(2) the socket to ensure the client isn't attempting to read from us (even if it explicitly stopped writes). --- lib/unicorn/stream_input.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/stream_input.rb b/lib/unicorn/stream_input.rb index 4ca5a045..c8a4240b 100644 --- a/lib/unicorn/stream_input.rb +++ b/lib/unicorn/stream_input.rb @@ -139,7 +139,11 @@ private # we do support clients that shutdown(SHUT_WR) after the # _entire_ request has been sent, and those will not have # raised EOFError on us. - @socket.close if @socket + if @socket + @socket.shutdown + @socket.close + end + ensure raise Unicorn::ClientShutdown, "bytes_read=#{@bytes_read}", [] end end -- 2.11.4.GIT