Permalink
Browse files

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).
  • Loading branch information...
1 parent 04901da commit 4551c8ad4d63d4031c618f76d39532b39e88f9be Eric Wong committed Apr 27, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/unicorn/stream_input.rb
@@ -139,7 +139,11 @@ def eof!
# 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

0 comments on commit 4551c8a

Please sign in to comment.