diff options
-rw-r--r-- | lib/yahns/wbuf.rb | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb index 21bccce..991557e 100644 --- a/lib/yahns/wbuf.rb +++ b/lib/yahns/wbuf.rb @@ -30,16 +30,9 @@ require_relative 'wbuf_common' class Yahns::Wbuf # :nodoc: include Yahns::WbufCommon - # TODO: Figure out why this hack is needed to pass output buffering tests. - # It could be a bug in our code, Ruby, the sendfile gem, or FreeBSD itself. - # Tested on FreeBSD fbsd 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898 - # We are able to use bypass mode on Linux to reduce buffering in some - # cases. Without bypass mode, we must always finish writing the entire - # response completely before sending more data to the client. - bypass_ok = RUBY_PLATFORM =~ /linux/ - def initialize(body, persist, tmpdir) @tmpio = Yahns::TmpIO.new(tmpdir) + @tmpdir = tmpdir @sf_offset = @sf_count = 0 @wbuf_persist = persist # whether or not we keep the connection alive @body = body @@ -71,16 +64,12 @@ class Yahns::Wbuf # :nodoc: # we're all caught up, try to prevent dirty data from getting flushed # to disk if we can help it. - @tmpio.truncate(@sf_offset = 0) - @tmpio.rewind + @tmpio.close + @sf_offset = 0 + @tmpio = Yahns::TmpIO.new(@tmpdir) @bypass = true nil - end if bypass_ok - - def wbuf_write(client, buf) - @sf_count += @tmpio.write(buf) - :wait_writable - end unless bypass_ok + end # called by last wbuf_flush def wbuf_close(client) |