summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-19 00:23:00 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-19 00:23:00 (GMT)
commitcfeb344bf2f2801b9b32c69a7ca10f812bfae94f (patch)
tree8528427c09b02558bd3df8817c7940ad5046bd8c /thread_pthread.c
parentbff57efca187bcdb4b183229cb913a55da6d9cf5 (diff)
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
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 5e65e13..eec4bca 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 */