[nginx] Thread pools: create threads in detached state.

Ruslan Ermilov ru at nginx.com
Fri Aug 26 10:44:01 UTC 2016


details:   http://hg.nginx.org/nginx/rev/33d075b9097d
branches:  
changeset: 6667:33d075b9097d
user:      Piotr Sikora <piotrsikora at google.com>
date:      Mon Aug 15 05:52:04 2016 -0700
description:
Thread pools: create threads in detached state.

This prevents theoretical resource leak, since those threads are never joined.

Found with ThreadSanitizer.

Signed-off-by: Piotr Sikora <piotrsikora at google.com>

diffstat:

 src/core/ngx_thread_pool.c |  7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diffs (17 lines):

diff -r 3f82c1e7e29e -r 33d075b9097d src/core/ngx_thread_pool.c
--- a/src/core/ngx_thread_pool.c	Thu Aug 25 12:59:39 2016 +0300
+++ b/src/core/ngx_thread_pool.c	Mon Aug 15 05:52:04 2016 -0700
@@ -137,6 +137,13 @@ ngx_thread_pool_init(ngx_thread_pool_t *
         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) {



More information about the nginx-devel mailing list