From d5400442b931e31f0edf7d184b18845e728f867d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 7 Apr 2015 22:08:43 +0000 Subject: wbuf: fix writev calls for vectors 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. --- lib/yahns/wbuf.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') 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... -- cgit v1.2.3-24-ge0c7