summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-24 02:52:46 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-24 02:52:46 +0000
commit72ad081145fee3ebd444fbc437f1538d083ded90 (patch)
tree8256997fef113ab472b9c0f5ac535947539c5a70 /thread_pthread.c
parentfa31e1a4189d9d055c7e317da635fd84396d6249 (diff)
thread_pthread.c: avoid reading th pointer for thread cache
I suspect GC may free the rb_thread_t (th) pointer by the time we call register_cached_thread_and_wait. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 91d7215914..e17ca36819 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -436,7 +436,7 @@ native_thread_destroy(rb_thread_t *th)
#endif
#if USE_THREAD_CACHE
-static rb_thread_t *register_cached_thread_and_wait(rb_nativethread_id_t);
+static rb_thread_t *register_cached_thread_and_wait(void);
#endif
#if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP
@@ -841,7 +841,7 @@ thread_start_func_1(void *th_ptr)
#if USE_THREAD_CACHE
if (1) {
/* cache thread */
- if ((th = register_cached_thread_and_wait(th->thread_id)) != 0) {
+ if ((th = register_cached_thread_and_wait()) != 0) {
goto thread_start;
}
}
@@ -880,14 +880,14 @@ thread_cache_reset(void)
#endif
static rb_thread_t *
-register_cached_thread_and_wait(rb_nativethread_id_t thread_self_id)
+register_cached_thread_and_wait(void)
{
struct timespec end = { THREAD_CACHE_TIME, 0 };
struct cached_thread_entry entry;
rb_native_cond_initialize(&entry.cond);
entry.th = NULL;
- entry.thread_id = thread_self_id;
+ entry.thread_id = pthread_self();
end = native_cond_timeout(&entry.cond, end);
rb_native_mutex_lock(&thread_cache_lock);