From 291afc96bd4909fc3504df196c4370fe745cb9ee Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 14 Aug 2018 02:24:37 +0000 Subject: [PATCH] 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 --- thread_pthread.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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));