diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-04 22:16:52 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-04 22:34:09 +0000 |
commit | 39b178cdebe275cbc8ce19cf269bea7cd15ff4ca (patch) | |
tree | b7628ed278895fcf70ea3206956be586ac9e1ac5 /lib/rainbows/writer_thread_spawn.rb | |
parent | 75f5aa9a0d6b37a94afbea3121fc2c16e70a2b1d (diff) | |
download | rainbows-39b178cdebe275cbc8ce19cf269bea7cd15ff4ca.tar.gz |
This hopefully allows the "sendfile" gem to be required anywhere in the Rainbows!/Unicorn config file, and not have to be required via RUBYOPT or the '-r' command-line switch. We also modularize HttpResponse and avoids singleton methods in the response path. This (hopefully) makes it easier for individual concurrency models to share code and override individual methods.
Diffstat (limited to 'lib/rainbows/writer_thread_spawn.rb')
-rw-r--r-- | lib/rainbows/writer_thread_spawn.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/rainbows/writer_thread_spawn.rb b/lib/rainbows/writer_thread_spawn.rb index 0a8988f..e1f9e53 100644 --- a/lib/rainbows/writer_thread_spawn.rb +++ b/lib/rainbows/writer_thread_spawn.rb @@ -28,6 +28,8 @@ module Rainbows # used to wrap a BasicSocket to use with +q+ for all writes # this is compatible with IO.select class MySocket < Struct.new(:to_io, :q, :thr) + include Rainbows::HttpResponse + def readpartial(size, buf = "") to_io.readpartial(size, buf) end @@ -51,7 +53,7 @@ module Rainbows begin arg1, arg2 = response case arg1 - when :body then Base.write_body(io, arg2) + when :body then write_body(io, arg2) when :close io.close unless io.closed? break @@ -71,7 +73,7 @@ module Rainbows (self.q ||= queue_writer) << buf end - def write_body(body) + def queue_body(body) (self.q ||= queue_writer) << [ :body, body ] end @@ -89,7 +91,7 @@ module Rainbows end def write_body(my_sock, body) - my_sock.write_body(body) + my_sock.queue_body(body) end def process_client(client) @@ -98,6 +100,7 @@ module Rainbows def worker_loop(worker) MySocket.const_set(:MAX, worker_connections) + Rainbows::HttpResponse.setup(MySocket) super(worker) # accept loop from Unicorn CUR.delete_if do |t,q| q << nil |