about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-08-18 11:59:16 -0700
committerEric Wong <normalperson@yhbt.net>2009-08-18 11:59:16 -0700
commit69650f8f09fca2c7df3230e2bf054961a5292e52 (patch)
tree2e96ef4fd28b7ebf02381b264c5fc3a927556dd2
parent4e81d6f2e2a6a6b3de15bbd0e08992dd4630fa4b (diff)
downloadunicorn-69650f8f09fca2c7df3230e2bf054961a5292e52.tar.gz
The Revactor::TCP::Socket#read method without any arguments is
more or less equivalent to TCPSocket#readpartial without an
explicit buffer.  Since we rely on the buffer being
modified/replaced, monkey patch that object it to replace the
buffer with our own since we rely on modifying the existing
buffer passed to us.
-rw-r--r--lib/unicorn/tee_input.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb
index fcf4a95..aa1dff3 100644
--- a/lib/unicorn/tee_input.rb
+++ b/lib/unicorn/tee_input.rb
@@ -23,6 +23,13 @@ module Unicorn
         @tmp.write(@buf2)
         @tmp.seek(0)
       end
+
+      # give our socket object a readpartial if it can't handle it
+      if socket && ! socket.respond_to?(:readpartial)
+        def socket.readpartial(nr, buf = Unicorn::Z.dup)
+          buf.replace(read)
+        end
+      end
     end
 
     # returns the size of the input.  This is what the Content-Length