From c3a0a52c29f5ca39f3c8d1c8968e8ffe61e06f08 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 13 Apr 2022 10:48:13 -0700 Subject: Fix "reject insanely long boundaries" test hang At least on OpenBSD, this test occasionally hangs, because the `wr.write` does not return/raise after the `rd.close` in the other thread. Switch to `write_nonblock` with `exception: false`, using Thread.pass if the write would block. With this change, the test takes less than two seconds and does not hang. --- test/spec_multipart.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/spec_multipart.rb b/test/spec_multipart.rb index 1fea0808..8683cbc2 100644 --- a/test/spec_multipart.rb +++ b/test/spec_multipart.rb @@ -131,7 +131,11 @@ describe Rack::Multipart do # make the initial boundary a few gigs long longer = "0123456789" * 1024 * 1024 - (1024 * 1024).times { wr.write(longer) } + (1024 * 1024).times do + while wr.write_nonblock(longer, exception: false) == :wait_writable + Thread.pass + end + end wr.write("\r\n") wr.write('content-disposition: form-data; name="a"; filename="a.txt"') -- cgit v1.2.3-24-ge0c7