1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* thread.c (double2timeval): convert the infinity to TIME_MAX to avoid

SEGV by Thread.new {}.join(Float::INFINITY) on
  Debian GNU/Linux (amd64).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-03-26 13:16:31 +00:00
parent e1540cd74d
commit 79f7521e9b
2 changed files with 15 additions and 3 deletions

View file

@ -1,3 +1,9 @@
Tue Mar 26 22:14:46 2013 Tanaka Akira <akr@fsij.org>
* thread.c (double2timeval): convert the infinity to TIME_MAX to avoid
SEGV by Thread.new {}.join(Float::INFINITY) on
Debian GNU/Linux (amd64).
Mon Mar 25 07:09:20 2013 Eric Hodel <drbrain@segment7.net>
* lib/rinda/tuplespace.rb: Only return tuple entry once on move,

View file

@ -73,6 +73,9 @@
#define THREAD_DEBUG 0
#endif
#define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))
#define TIMET_MIN (~(time_t)0 <= 0 ? (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1)) : (time_t)0)
VALUE rb_cMutex;
VALUE rb_cThreadShield;
@ -916,6 +919,12 @@ double2timeval(double d)
{
struct timeval time;
if (isinf(d)) {
time.tv_sec = TIMET_MAX;
time.tv_usec = 0;
return time;
}
time.tv_sec = (int)d;
time.tv_usec = (int)((d - (int)d) * 1e6);
if (time.tv_usec < 0) {
@ -3551,9 +3560,6 @@ rb_thread_fd_select(int max, rb_fdset_t * read, rb_fdset_t * write, rb_fdset_t *
#define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR)
#define POLLEX_SET (POLLPRI)
#define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))
#define TIMET_MIN (~(time_t)0 <= 0 ? (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1)) : (time_t)0)
#ifndef HAVE_PPOLL
/* TODO: don't ignore sigmask */
int