diff options
author | Eric Wong <e@80x24.org> | 2015-04-07 22:08:43 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-04-07 22:09:23 +0000 |
commit | d5400442b931e31f0edf7d184b18845e728f867d (patch) | |
tree | 106c50ef2ec9e2c99d70ccfcffb01547b59f69ea /lib | |
parent | 76cc538fd8962eb380e8980a78d59b2133880196 (diff) | |
download | yahns-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.rb | 7 |
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... |