Skip to content

Commit 240ee63

Browse files
committed
Disable meaningless and unpredictable spec for #2332.
1 parent 38d064f commit 240ee63

File tree

1 file changed

+61
-28
lines changed

1 file changed

+61
-28
lines changed

spec/regression/JRUBY-5122_nonblocking_io_spec.rb

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -209,45 +209,78 @@
209209
value.should == "baz"
210210
end
211211

212+
# WRITE BLOCKAGE:
213+
#
214+
# We try to pick a suitably large value such that potentially-blocking
215+
# writes are more likely to reach buffer limits and actually block.
216+
#
212217
# On an Ubuntu 10.10(64) box:
213218
# Packaged OpenJDK6 block with > 152606 (?)
214219
# Oracle's build block with > 131072 (2**17)
215220
# On a Windows 7(64) box:
216221
# Oracle's build does not block (use memory till OOMException)
217222
SOCKET_CHANNEL_MIGHT_BLOCK = "a" * (219463 * 4)
218223

224+
# This spec does not appear to test anything meaningful and occasionally
225+
# failed due to several inherent races. I improved the race situation
226+
# somewhat, but it's unclear whether this spec can ever fail since it
227+
# appears to accept both blocking and nonblocking write.
228+
#
229+
# I believe the spec originally expected small writes not to block, which
230+
# is reasonable, but at some point it mutated into a test that write
231+
# *does* block under certain circumstances, making the original assertions
232+
# meaningless.
233+
#
234+
# See jruby/jruby#2332
235+
236+
=begin
219237
it "should not block for write" do
220-
100.times do # for acceleration; it failed w/o wait_for_accepted call
221-
server = TCPServer.new(0)
222-
value = nil
223-
t = Thread.new {
224-
sock = accept(server)
225-
begin
226-
value = 1
227-
# this could block; [ruby-dev:26405] But it doesn't block on Windows.
228-
sock.write(SOCKET_CHANNEL_MIGHT_BLOCK)
229-
value = 2
230-
rescue RuntimeError
231-
value = 3
232-
end
233-
}
234-
s = connect(server)
235-
type = nil
236-
wait_for_sleep_and_terminate(t) do
237-
if value == 1
238-
type = :blocked
239-
t.raise # help thread termination
240-
else
241-
value.should == 2
242-
t.status.should == false
238+
100.times do # for acceleration; it failed w/o wait_for_accepted call
239+
server = TCPServer.new(0)
240+
value = nil
241+
t = Thread.new {
242+
sock = accept(server)
243+
begin
244+
value = 1
245+
# this could block; [ruby-dev:26405] But it doesn't block on Windows.
246+
sock.write(SOCKET_CHANNEL_MIGHT_BLOCK)
247+
value = 2
248+
rescue RuntimeError
249+
value = 3
250+
end
251+
}
252+
s = connect(server)
253+
254+
# Whether write blocks or not, read will block until data is available
255+
IO.select([s], nil, nil, 2)
256+
257+
# If write did not block, give thread some time to advance
258+
100.times { Thread.pass }
259+
260+
# Now check where we are
261+
wait_for_sleep_and_terminate(t) do
262+
if value == 1
263+
264+
# Write blocked [ruby-dev:26405], see WRITE BLOCKAGE above
265+
type = :blocked
266+
t.raise # help thread termination
267+
t.join
268+
269+
if RbConfig::CONFIG['host_os'] !~ /mingw|mswin/
270+
value.should == 3
271+
t.status.should == false
272+
end
273+
274+
else
275+
276+
# Write did not block
277+
value.should == 2
278+
t.status.should == false
279+
end
243280
end
244281
end
245-
if type == :blocked && RbConfig::CONFIG['host_os'] !~ /mingw|mswin/
246-
value.should == 3
247-
t.status.should == false
248-
end
249-
end
250282
end
283+
=end
251284

252285
it "should not block for write_nonblock" do
253286
server = TCPServer.new(0)

0 commit comments

Comments
 (0)