From 72ff908eaffd3dcab63a69f898673d96c2a9226b Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 1 Jun 2018 13:45:09 -0700 Subject: [PATCH] Initialize condattr_monotonic via pthread_condattr_init Some operating systems will work without calling pthread_condattr_init, but some won't (such as OpenBSD). Prior to r63238, pthread_condattr_init was always called before calling pthread_condattr_setclock. --- thread_pthread.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/thread_pthread.c b/thread_pthread.c index e17ca36819..069c50ed7a 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -399,7 +399,10 @@ Init_native_thread(rb_thread_t *th) { #if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) if (condattr_monotonic) { - int r = pthread_condattr_setclock(condattr_monotonic, CLOCK_MONOTONIC); + int r = pthread_condattr_init(condattr_monotonic); + if (r == 0) { + r = pthread_condattr_setclock(condattr_monotonic, CLOCK_MONOTONIC); + } if (r) condattr_monotonic = NULL; } #endif -- 2.16.2