about summary refs log tree commit homepage
path: root/lib/yahns/wbuf_lite.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-07-19 21:47:01 +0000
committerEric Wong <e@80x24.org>2016-07-19 21:58:42 +0000
commit7a211796fd643abf14692cab0b76e97d850219a4 (patch)
tree29c30301563edb3b3446fb193082870d2729362c /lib/yahns/wbuf_lite.rb
parentc97b5254d6cc50264786270cdd09ed9485a5bec6 (diff)
downloadyahns-7a211796fd643abf14692cab0b76e97d850219a4.tar.gz
All of our wbuf code assumes we append to existing buffers
(files) since sendfile cannot deal otherwise.  We also
follow this pattern for StringIO to avoid extra data copies.
Diffstat (limited to 'lib/yahns/wbuf_lite.rb')
-rw-r--r--lib/yahns/wbuf_lite.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/yahns/wbuf_lite.rb b/lib/yahns/wbuf_lite.rb
index 1902ce7..8a93ad1 100644
--- a/lib/yahns/wbuf_lite.rb
+++ b/lib/yahns/wbuf_lite.rb
@@ -33,6 +33,7 @@ class Yahns::WbufLite # :nodoc:
     end until @busy
 
     @tmpio ||= StringIO.new(''.dup) # relies on encoding: binary above
+    @tmpio.seek(0, 2) # fake O_APPEND behavior
     @sf_count += @tmpio.write(buf)
 
     # we spent some time copying to the FS, try to write to
@@ -45,12 +46,12 @@ class Yahns::WbufLite # :nodoc:
       @busy = rv
       return rv
     else
-      raise "BUG: #{rv.nil? ? "EOF" : rv.inspect} on tmpio " \
+      raise "BUG: #{rv.nil? ? 'EOF' : rv.inspect} on "
+            "tmpio.size=#{@tmpio.size} " \
             "sf_offset=#@sf_offset sf_count=#@sf_count"
     end while @sf_count > 0
 
-    # we're all caught up, try to prevent dirty data from getting flushed
-    # to disk if we can help it.
+    # we're all caught up, try to save some memory if we can help it.
     wbuf_abort
     @sf_offset = 0
     @busy = false