summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--thread.c12
2 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 35da5a8845..25dc188afb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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,
diff --git a/thread.c b/thread.c
index e9fe8a7ddf..189a563c44 100644
--- a/thread.c
+++ b/thread.c
@@ -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