From 3d406e7277080870dd7f363e71a8924f1602a17e Mon Sep 17 00:00:00 2001 From: zhengshuxin Date: Wed, 6 Sep 2017 22:03:27 +0800 Subject: [PATCH] init_conf_str_vars in master_params.cpp has memory leak when master reload configure. --- app/master/daemon/changes.txt | 2 ++ app/master/daemon/master/master_params.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/master/daemon/changes.txt b/app/master/daemon/changes.txt index 5d5185fc1..5a08c84ed 100644 --- a/app/master/daemon/changes.txt +++ b/app/master/daemon/changes.txt @@ -2,6 +2,8 @@ 6) 2017.9.5 6.1) feature: master can wait children to exit with sync or async 6.2) feature: master can kill SIGTERM children when reloading +6.3) bugfix: master_params.cpp 中的 init_conf_str_vars 函数在 master reload 时 +有内存泄露 5) 2017.8.11 5.1) safety: master can't fatal for some configure error of any app service. diff --git a/app/master/daemon/master/master_params.cpp b/app/master/daemon/master/master_params.cpp index 0c2669d59..a499df2eb 100644 --- a/app/master/daemon/master/master_params.cpp +++ b/app/master/daemon/master/master_params.cpp @@ -92,12 +92,13 @@ static void init_conf_int_vars(ACL_CONFIG_INT_TABLE cit[]) static void init_conf_str_vars(ACL_CONFIG_STR_TABLE cst[]) { int i; + static int first_call = 1; for (i = 0; cst[i].name != 0; i++) { - /* - if (*(cst[i].target) != 0) + if (first_call) + first_call = 0; + else if (*(cst[i].target) != 0) acl_myfree(*(cst[i].target)); - */ *(cst[i].target) = acl_mystrdup(cst[i].defval); } }