about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/yahns/wbuf_common.rb3
-rw-r--r--test/test_wbuf.rb4
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/yahns/wbuf_common.rb b/lib/yahns/wbuf_common.rb
index b3a4502..a3e737b 100644
--- a/lib/yahns/wbuf_common.rb
+++ b/lib/yahns/wbuf_common.rb
@@ -25,7 +25,8 @@ module Yahns::WbufCommon # :nodoc:
       raise "BUG: rv=#{rv.inspect} " \
             "on tmpio=#{@tmpio.inspect} " \
             "sf_offset=#@sf_offset sf_count=#@sf_count"
-    end while true
+    end while @sf_count > 0
+    wbuf_close(client)
   end
 
   def wbuf_close_common(client)
diff --git a/test/test_wbuf.rb b/test/test_wbuf.rb
index 25cdeba..644c76b 100644
--- a/test/test_wbuf.rb
+++ b/test/test_wbuf.rb
@@ -81,8 +81,8 @@ class TestWbuf < Testcase
     assert_equal b, IO.select([b], nil, nil, 5)[0][0]
     b.read(nr - 2) if nr > 2
     assert_equal b, IO.select([b], nil, nil, 5)[0][0]
-    assert_equal "HI", b.read(2)
-    assert_equal false, wbuf.wbuf_flush(a)
+    assert_equal "HI", b.read(2), "read the end of the response"
+    assert_equal true, wbuf.wbuf_flush(a)
   ensure
     a.close
     b.close