From 2554f0675998c91201906f422ef1fb5914a2d61c Mon Sep 17 00:00:00 2001 From: z3APA3A <3APA3A@3proxy.ru> Date: Wed, 13 Sep 2017 22:05:38 +0300 Subject: [PATCH] pthread_attr_destroy added to prevent memory leak on config reload --- src/conf.c | 1 + src/proxymain.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/conf.c b/src/conf.c index ae8177a..6794d37 100644 --- a/src/conf.c +++ b/src/conf.c @@ -161,6 +161,7 @@ int start_proxy_thread(struct child * chp){ pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (16384+conf.stacksize)); pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED); pthread_create(&thread, &pa, startsrv, (void *)chp); + pthread_attr_destroy(&pa); #endif while(conf.threadinit)usleep(SLEEPTIME); if(haveerror) { diff --git a/src/proxymain.c b/src/proxymain.c index 7d21e7b..e9d7e7c 100644 --- a/src/proxymain.c +++ b/src/proxymain.c @@ -830,6 +830,9 @@ int MODULEMAINFUNC (int argc, char** argv){ pthread_mutex_unlock(&config_mutex); #endif +#ifndef _WIN32 + pthread_attr_destroy(&pa); +#endif if(defparam.hostname)myfree(defparam.hostname); if(cbc_string)myfree(cbc_string); if(cbl_string)myfree(cbl_string);