mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
bff57efca1
commit
cfeb344bf2
1 changed files with 9 additions and 7 deletions
|
@ -1763,18 +1763,20 @@ rb_thread_create_mjit_thread(void (*child_hook)(void), void (*worker_func)(void)
|
||||||
{
|
{
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_t worker_pid;
|
pthread_t worker_pid;
|
||||||
|
int ret = FALSE;
|
||||||
|
|
||||||
pthread_atfork(NULL, NULL, child_hook);
|
pthread_atfork(NULL, NULL, child_hook);
|
||||||
if (pthread_attr_init(&attr) == 0
|
|
||||||
/* jit_worker thread is not to be joined */
|
if (pthread_attr_init(&attr) != 0) return ret;
|
||||||
&& pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0
|
|
||||||
|
/* 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_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) == 0
|
||||||
&& pthread_create(&worker_pid, &attr, mjit_worker, (void *)worker_func) == 0) {
|
&& pthread_create(&worker_pid, &attr, mjit_worker, (void *)worker_func) == 0) {
|
||||||
return TRUE;
|
ret = TRUE;
|
||||||
}
|
|
||||||
else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
pthread_attr_destroy(&attr);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */
|
#endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */
|
||||||
|
|
Loading…
Reference in a new issue