about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-04-07 22:08:43 +0000
committerEric Wong <e@80x24.org>2015-04-07 22:09:23 +0000
commitd5400442b931e31f0edf7d184b18845e728f867d (patch)
tree106c50ef2ec9e2c99d70ccfcffb01547b59f69ea /lib
parent76cc538fd8962eb380e8980a78d59b2133880196 (diff)
downloadyahns-d5400442b931e31f0edf7d184b18845e728f867d.tar.gz
kgio_writev returns nil on success instead of the number of bytes
written, so we must manually calculate the number of bytes written
intead :x

This is triggerable when sending giant chunked responses.
Diffstat (limited to 'lib')
-rw-r--r--lib/yahns/wbuf.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb
index 42776cf..9888a8c 100644
--- a/lib/yahns/wbuf.rb
+++ b/lib/yahns/wbuf.rb
@@ -41,6 +41,11 @@ class Yahns::Wbuf # :nodoc:
     @busy = busy # may be false
   end
 
+  def wbuf_writev(buf)
+    @tmpio.kgio_writev(buf)
+    buf.inject(0) { |n, s| n += s.size }
+  end
+
   def wbuf_write(c, buf)
     # try to bypass the VFS layer and write directly to the socket
     # if we're all caught up
@@ -54,7 +59,7 @@ class Yahns::Wbuf # :nodoc:
     end until @busy
 
     @tmpio ||= Yahns::TmpIO.new(@tmpdir)
-    @sf_count += String === buf ? @tmpio.write(buf) : @tmpio.kgio_writev(buf)
+    @sf_count += String === buf ? @tmpio.write(buf) : wbuf_writev(buf)
 
     # we spent some time copying to the FS, try to write to
     # the socket again in case some space opened up...