summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-01 21:56:11 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-01 21:56:11 (GMT)
commit832b601e49fd402ec7f30b36a95473131e93ae94 (patch)
tree63f22ca5f8c77a9e821d486e866f3fada78c4c88 /thread_pthread.c
parent24c6231e116bb7fd933dbc4a1b3236d8c32a2e31 (diff)
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. From: Jeremy Evans <code@jeremyevans.net> [ruby-core:87345] [Ruby trunk Bug#14807] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index e17ca36..069c50e 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