diff options
author | Eric Wong <normalperson@yhbt.net> | 2012-04-27 14:42:38 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-04-27 14:42:38 -0700 |
commit | 4551c8ad4d63d4031c618f76d39532b39e88f9be (patch) | |
tree | 970ae12e177777c983b528740fb7d054fec5cfb5 | |
parent | 04901da5ae0b4655c83be05d24ae737f1b572002 (diff) | |
download | unicorn-4551c8ad4d63d4031c618f76d39532b39e88f9be.tar.gz |
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).
-rw-r--r-- | lib/unicorn/stream_input.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/unicorn/stream_input.rb b/lib/unicorn/stream_input.rb index 4ca5a04..c8a4240 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 |