about summary refs log tree commit homepage
path: root/test/test_wbuf.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-11-01 10:50:38 +0000
committerEric Wong <normalperson@yhbt.net>2013-11-01 10:50:38 +0000
commit4d3fe8b58e707670ba40dda83ec460adca0596a3 (patch)
treef725fee22388fb3ed6ed4a600e8cba82e216bb57 /test/test_wbuf.rb
parent93ba820f05aaf8c760b4a515ae996425c257a7fb (diff)
downloadyahns-4d3fe8b58e707670ba40dda83ec460adca0596a3.tar.gz
Sometimes buffering can catch up and we no longer need to
use the on-disk buffer, so keep trying to flush the data
out to the user to avoid VFS activity.
Diffstat (limited to 'test/test_wbuf.rb')
-rw-r--r--test/test_wbuf.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/test/test_wbuf.rb b/test/test_wbuf.rb
index 44ac74e..03abbac 100644
--- a/test/test_wbuf.rb
+++ b/test/test_wbuf.rb
@@ -6,12 +6,20 @@ require 'timeout'
 class TestWbuf < Testcase
   ENV["N"].to_i > 1 and parallelize_me!
 
+  class KgioUS < UNIXSocket
+    include Kgio::SocketMethods
+  end
+
+  def socketpair
+    KgioUS.pair.each { |io| io.close_on_exec = true }
+  end
+
   def test_wbuf
     buf = "*" * (16384 * 2)
     nr = 1000
     [ true, false ].each do |persist|
       wbuf = Yahns::Wbuf.new([], persist)
-      a, b = UNIXSocket.pair
+      a, b = socketpair
       assert_nil wbuf.wbuf_write(a, "HIHI")
       assert_equal "HIHI", b.read(4)
       nr.times { wbuf.wbuf_write(a, buf) }
@@ -50,7 +58,7 @@ class TestWbuf < Testcase
   end
 
   def test_wbuf_blocked
-    a, b = UNIXSocket.pair
+    a, b = socketpair
     buf = "." * 4096
     4.times do
       begin
@@ -90,7 +98,7 @@ class TestWbuf < Testcase
     persist = true
     wbuf = Yahns::Wbuf.new(pipe[0], persist)
     refute wbuf.respond_to?(:close) # we don't want this for HttpResponse body
-    sp = UNIXSocket.pair
+    sp = socketpair
     rv = nil
 
     buf = ("*" * 16384) << "\n"