Fix test thread leakage
This commit is contained in:
parent
f38f8d4f4a
commit
94d7c70801
@ -447,13 +447,12 @@ class TestSocket < Test::Unit::TestCase
|
|||||||
omit "UDP server is no response: #{$!}"
|
omit "UDP server is no response: #{$!}"
|
||||||
ensure
|
ensure
|
||||||
if th
|
if th
|
||||||
if skipped
|
unless skipped
|
||||||
Thread.kill th unless th.join(10)
|
|
||||||
else
|
|
||||||
Addrinfo.udp("127.0.0.1", port).connect {|s| s.sendmsg "exit" }
|
Addrinfo.udp("127.0.0.1", port).connect {|s| s.sendmsg "exit" }
|
||||||
|
end
|
||||||
unless th.join(10)
|
unless th.join(10)
|
||||||
Thread.kill th
|
th.kill.join(10)
|
||||||
th.join(10)
|
unless skipped
|
||||||
raise "thread killed"
|
raise "thread killed"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -497,6 +496,7 @@ class TestSocket < Test::Unit::TestCase
|
|||||||
assert(stamp.cmsg_is?(:SOCKET, type))
|
assert(stamp.cmsg_is?(:SOCKET, type))
|
||||||
w.close # stop th
|
w.close # stop th
|
||||||
n = th.value
|
n = th.value
|
||||||
|
th = nil
|
||||||
n > 1 and
|
n > 1 and
|
||||||
warn "UDP packet loss for #{type} over loopback, #{n} tries needed"
|
warn "UDP packet loss for #{type} over loopback, #{n} tries needed"
|
||||||
t2 = Time.now.strftime("%Y-%m-%d")
|
t2 = Time.now.strftime("%Y-%m-%d")
|
||||||
@ -505,6 +505,10 @@ class TestSocket < Test::Unit::TestCase
|
|||||||
t = stamp.timestamp
|
t = stamp.timestamp
|
||||||
assert_match(pat, t.strftime("%Y-%m-%d"))
|
assert_match(pat, t.strftime("%Y-%m-%d"))
|
||||||
stamp
|
stamp
|
||||||
|
ensure
|
||||||
|
if th and !th.join(10)
|
||||||
|
th.kill.join(10)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user