diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-04-13 10:48:13 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2022-04-20 09:25:59 -0700 |
commit | c3a0a52c29f5ca39f3c8d1c8968e8ffe61e06f08 (patch) | |
tree | 874d528ed1093ce90ea13c72ae43ad1f69b51934 | |
parent | cd4b3c934a8681f5d15053295b7dc34d56b2ccad (diff) | |
download | rack-c3a0a52c29f5ca39f3c8d1c8968e8ffe61e06f08.tar.gz |
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.
-rw-r--r-- | test/spec_multipart.rb | 6 |
1 files changed, 5 insertions, 1 deletions
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"') |