dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] wbuf: fix writev
Date: Tue,  7 Apr 2015 21:52:02 +0000	[thread overview]
Message-ID: <1428443522-5828-1-git-send-email-e@80x24.org> (raw)

---
 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


                 reply	other threads:[~2015-04-07 21:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428443522-5828-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).