merge revision(s) 39939: [Backport #8360]

* 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/branches/ruby_2_0_0@40562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2013-05-02 14:40:29 +00:00
parent 5362d2e2cb
commit 453bb57d55
3 changed files with 16 additions and 4 deletions

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) {
@ -3509,9 +3518,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