[ruby-cvs:69643] normal:r62462 (trunk): thread.c (thread_join_m): handle negative timeouts correctly

normal at ruby-lang.org normal at ruby-lang.org
Sun Feb 18 12:00:34 JST 2018


normal	2018-02-18 12:00:33 +0900 (Sun, 18 Feb 2018)

  New Revision: 62462

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62462

  Log:
    thread.c (thread_join_m): handle negative timeouts correctly
    
    Users may subtract and round into negative values when using
    Thread#join, so clamp the timeout to zero to avoid infinite/long
    timeouts.
    
    Note: other methods such as Kernel#sleep and IO.select will
    raise on negative values, but Thread#join is an outlier *shrug*
    
    This restores Ruby 2.5 (and earlier) behavior.
    
    Fixes: r62182 (commit c915390b9530c31b4665aacf27c1adfc114f768e)
           ("thread.c: avoid FP for Thread#join")

  Modified files:
    trunk/test/ruby/test_thread.rb
    trunk/thread.c


More information about the ruby-cvs mailing list