about summary refs log tree commit homepage
path: root/lib/yahns/wbuf_common.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/yahns/wbuf_common.rb')
-rw-r--r--lib/yahns/wbuf_common.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/yahns/wbuf_common.rb b/lib/yahns/wbuf_common.rb
index cded2e3..2799baf 100644
--- a/lib/yahns/wbuf_common.rb
+++ b/lib/yahns/wbuf_common.rb
@@ -19,7 +19,10 @@ module Yahns::WbufCommon # :nodoc:
   def wbuf_flush(client)
     case rv = client.trysendfile(@tmpio, @sf_offset, @sf_count)
     when Integer
-      return wbuf_close(client) if (@sf_count -= rv) == 0 # all sent!
+      if (@sf_count -= rv) == 0 # all sent!
+        @sf_offset = 0
+        return wbuf_close(client)
+      end
 
       @sf_offset += rv # keep going otherwise
     when :wait_writable, :wait_readable