aboutsummaryrefslogtreecommitdiffstats
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-14 02:24:37 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-14 02:24:37 +0000
commite08fcceac7d582644a2c5738d90577b7a6e844bf (patch)
tree9385a3308b6eeab5cbb36d630d8f0e791a7dea19 /thread_pthread.c
parent26933a564102d356a184a1904ff4e082e050cd45 (diff)
downloadruby-e08fcceac7d582644a2c5738d90577b7a6e844bf.tar.gz
thread_pthread.c: use CLOCK_REALTIME on SunOS (Solaris)
timer_create does not seem to support CLOCK_MONOTONIC on Solaris, and CLOCK_HIRES seems like it could fail with insufficient permissions: https://docs.oracle.com/cd/E86824_01/html/E54766/timer-create-3c.html (Only tested on Linux and FreeBSD) [ruby-core:88360] [Misc #14937] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index bcf412bc2f..75ce110063 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1580,12 +1580,18 @@ static void
rb_timer_create(rb_pid_t current)
{
#if UBF_TIMER == UBF_TIMER_POSIX
+# if defined(__sun)
+# define UBF_TIMER_CLOCK CLOCK_REALTIME
+# else /* Tested Linux and FreeBSD: */
+# define UBF_TIMER_CLOCK CLOCK_MONOTONIC
+# endif
+
struct sigevent sev;
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = SIGVTALRM;
sev.sigev_value.sival_ptr = &timer_posix;
- if (!timer_create(CLOCK_MONOTONIC, &sev, &timer_posix.timerid))
+ if (!timer_create(UBF_TIMER_CLOCK, &sev, &timer_posix.timerid))
timer_posix.owner = current;
else
rb_warn("timer_create failed: %s, signals racy", strerror(errno));