diff options
-rw-r--r-- | lib/yahns/wbuf.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb index 10312db..8b2b82e 100644 --- a/lib/yahns/wbuf.rb +++ b/lib/yahns/wbuf.rb @@ -11,20 +11,19 @@ class Yahns::Wbuf # :nodoc: @sf_offset = @sf_count = 0 @wbuf_persist = persist # whether or not we keep the connection alive @body = body + @bypass = false end def wbuf_write(client, buf) # try to bypass the VFS layer if we're all caught up - if @sf_count == 0 - case rv = client.kgio_trywrite(buf) - when String - buf = rv # retry in loop - when nil - return nil # yay! hopefully we don't have to buffer again - when :wait_writable, :wait_readable - break # ugh, continue to buffering to file - end while true - end + case rv = client.kgio_trywrite(buf) + when String + buf = rv # retry in loop + when nil + return # yay! hopefully we don't have to buffer again + when :wait_writable, :wait_readable + @bypass = false # ugh, continue to buffering to file + end while @bypass @sf_count += @tmpio.write(buf) case rv = client.trysendfile(@tmpio, @sf_offset, @sf_count) @@ -42,6 +41,7 @@ class Yahns::Wbuf # :nodoc: # to disk if we can help it. @tmpio.truncate(@sf_offset = 0) @tmpio.rewind + @bypass = true nil end |