diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | thread.c | 12 |
2 files changed, 15 insertions, 3 deletions
@@ -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, @@ -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 |