]> git.kaiwu.me - nginx.git/commitdiff
Thread pools: create threads in detached state.
authorPiotr Sikora <piotrsikora@google.com>
Mon, 15 Aug 2016 12:52:04 +0000 (05:52 -0700)
committerPiotr Sikora <piotrsikora@google.com>
Mon, 15 Aug 2016 12:52:04 +0000 (05:52 -0700)
This prevents theoretical resource leak, since those threads are never joined.

Found with ThreadSanitizer.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
src/core/ngx_thread_pool.c

index f3655aa0bea1f1064150ccee2fe2837dcc27da25..7fb0f7f8d9286e3be30164dbe273a45f2fd76570 100644 (file)
@@ -137,6 +137,13 @@ ngx_thread_pool_init(ngx_thread_pool_t *tp, ngx_log_t *log, ngx_pool_t *pool)
         return NGX_ERROR;
     }
 
+    err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    if (err) {
+        ngx_log_error(NGX_LOG_ALERT, log, err,
+                      "pthread_attr_setdetachstate() failed");
+        return NGX_ERROR;
+    }
+
 #if 0
     err = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
     if (err) {