From cfeb344bf2f2801b9b32c69a7ca10f812bfae94f Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 19 Feb 2018 00:23:00 +0000 Subject: thread_pthread.c (rb_thread_create_mjit_thread): destroy attr This is required on some platforms to avoid leaks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 5e65e133f7..eec4bca7ca 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1763,18 +1763,20 @@ rb_thread_create_mjit_thread(void (*child_hook)(void), void (*worker_func)(void) { pthread_attr_t attr; pthread_t worker_pid; + int ret = FALSE; pthread_atfork(NULL, NULL, child_hook); - if (pthread_attr_init(&attr) == 0 - /* jit_worker thread is not to be joined */ - && pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0 + + if (pthread_attr_init(&attr) != 0) return ret; + + /* jit_worker thread is not to be joined */ + if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0 && pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) == 0 && pthread_create(&worker_pid, &attr, mjit_worker, (void *)worker_func) == 0) { - return TRUE; - } - else { - return FALSE; + ret = TRUE; } + pthread_attr_destroy(&attr); + return ret; } #endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */ -- cgit v1.2.3