diff options
-rw-r--r-- | lib/yahns/wbuf.rb | 1 | ||||
-rw-r--r-- | lib/yahns/wbuf_lite.rb | 7 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb index 583df10..3abc5f9 100644 --- a/lib/yahns/wbuf.rb +++ b/lib/yahns/wbuf.rb @@ -58,6 +58,7 @@ class Yahns::Wbuf # :nodoc: end until @busy @tmpio ||= Yahns::TmpIO.new(c.class.output_buffer_tmpdir) + # n.b.: we rely on O_APPEND in TmpIO, here @sf_count += String === buf ? @tmpio.write(buf) : wbuf_writev(buf) # we spent some time copying to the FS, try to write to 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 |