dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] wbuf: fix writev
@ 2015-04-07 21:52 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-04-07 21:52 UTC (permalink / raw)
  To: spew

---
 lib/yahns/wbuf.rb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb
index 42776cf..a04565e 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
+    @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...
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-07 21:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 21:52 [PATCH] wbuf: fix writev Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).