summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-19 09:28:51 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-19 09:28:51 +0000
commit4651ef77d2f434fe113b9c65adf143bc0650a6ca (patch)
tree010dfcc37f7138f2d81bcf4d84546b15ba938e0e /thread_pthread.c
parent628be3b7dcbf35e65d69c64c66be876b00b3cbe4 (diff)
downloadruby-4651ef77d2f434fe113b9c65adf143bc0650a6ca.tar.gz
thread_pthread.c: fix thread cache for non-monotonic clock
I noticed this because of https://bugs.ruby-lang.org/issues/14494 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 4818f61e7a..12f5e6c473 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -894,15 +894,13 @@ thread_cache_reset(void)
static rb_thread_t *
register_cached_thread_and_wait(rb_nativethread_id_t thread_self_id)
{
- struct timespec end;
+ struct timespec end = { 60, 0 };
struct cached_thread_entry entry;
rb_native_cond_initialize(&entry.cond, RB_CONDATTR_CLOCK_MONOTONIC);
entry.th = NULL;
entry.thread_id = thread_self_id;
-
- getclockofday(&end);
- end.tv_sec += 60;
+ end = native_cond_timeout(&entry.cond, end);
rb_native_mutex_lock(&thread_cache_lock);
{