about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-02-08 03:08:27 -0500
committerEric Wong <e@80x24.org>2014-02-08 08:35:02 +0000
commitdda19354de0bc72c1ab7ea49537a0ae2b019e837 (patch)
treef404df6e7d9f17f23afb18e83d1178e3d04b0300
parentd084e6caa23b585a62065b9c89503deb69be72e3 (diff)
downloadyahns-dda19354de0bc72c1ab7ea49537a0ae2b019e837.tar.gz
We may unnecessarily drop persistent connections from this bug,
and we had an incorrect assertion in our unit test, even.
-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