summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-04-27 14:42:38 -0700
committerEric Wong <normalperson@yhbt.net>2012-04-27 14:42:38 -0700
commit4551c8ad4d63d4031c618f76d39532b39e88f9be (patch)
tree970ae12e177777c983b528740fb7d054fec5cfb5
parent04901da5ae0b4655c83be05d24ae737f1b572002 (diff)
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.rb6
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