about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-11-01 10:54:19 +0000
committerEric Wong <normalperson@yhbt.net>2013-11-01 11:08:58 +0000
commit6f2f45e08e4142edbe83dcaba632773a94900d71 (patch)
tree5abadd13bb93ea37a7313ee33253851abc3b0a0f
parent4d3fe8b58e707670ba40dda83ec460adca0596a3 (diff)
downloadyahns-6f2f45e08e4142edbe83dcaba632773a94900d71.tar.gz
This can prevent dirty data from being committed, saving the system
from unnecessary disk activity.
-rw-r--r--lib/yahns/wbuf.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb
index df7d56d..10312db 100644
--- a/lib/yahns/wbuf.rb
+++ b/lib/yahns/wbuf.rb
@@ -37,6 +37,11 @@ class Yahns::Wbuf # :nodoc:
       raise "BUG: #{rv.nil ? "EOF" : rv.inspect} on tmpio " \
             "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.
+    @tmpio.truncate(@sf_offset = 0)
+    @tmpio.rewind
     nil
   end