Project

General

Profile

Feature #20610 ยป select-timeout-infinity.patch

akr (Akira Tanaka), 07/07/2024 02:01 AM

View differences:

io.c
#endif
}
static int
is_pos_inf(VALUE x)
{
double f;
if (!RB_FLOAT_TYPE_P(x))
return 0;
f = RFLOAT_VALUE(x);
return isinf(f) && 0 < f;
}
/*
* call-seq:
* IO.select(read_ios, write_ios = [], error_ios = [], timeout = nil) -> array or nil
......
int i;
rb_scan_args(argc, argv, "13", &args.read, &args.write, &args.except, &timeout);
if (NIL_P(timeout)) {
if (NIL_P(timeout) || is_pos_inf(timeout)) {
args.timeout = 0;
}
else {
test/ruby/test_io.rb
end
end if Socket.const_defined?(:MSG_OOB)
def test_select_timeout
assert_equal(nil, IO.select(nil,nil,nil,0))
assert_equal(nil, IO.select(nil,nil,nil,0.0))
assert_raise(TypeError) { IO.select(nil,nil,nil,"invalid-timeout") }
assert_raise(ArgumentError) { IO.select(nil,nil,nil,-1) }
assert_raise(ArgumentError) { IO.select(nil,nil,nil,-0.1) }
assert_raise(ArgumentError) { IO.select(nil,nil,nil,-Float::INFINITY) }
assert_raise(RangeError) { IO.select(nil,nil,nil,Float::NAN) }
IO.pipe {|r, w|
w << "x"
ret = [[r], [], []]
assert_equal(ret, IO.select([r],nil,nil,0.1))
assert_equal(ret, IO.select([r],nil,nil,1))
assert_equal(ret, IO.select([r],nil,nil,Float::INFINITY))
}
end
def test_recycled_fd_close
dot = -'.'
IO.pipe do |sig_rd, sig_wr|
    (1-1/1)