[前][次][番号順一覧][スレッド一覧]

ruby-changes:50361

From: normal <ko1@a...>
Date: Mon, 19 Feb 2018 09:23:06 +0900 (JST)
Subject: [ruby-changes:50361] normal:r62477 (trunk): thread_pthread.c (rb_thread_create_mjit_thread): destroy attr

normal	2018-02-19 09:23:00 +0900 (Mon, 19 Feb 2018)

  New Revision: 62477

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62477

  Log:
    thread_pthread.c (rb_thread_create_mjit_thread): destroy attr
    
    This is required on some platforms to avoid leaks.

  Modified files:
    trunk/thread_pthread.c
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 62476)
+++ thread_pthread.c	(revision 62477)
@@ -1763,18 +1763,20 @@ rb_thread_create_mjit_thread(void (*chil https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1763
 {
     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 */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]