From ef9360fb3eab4edc8aa9d81be9ae3f9539623ee6 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Fri, 21 Jun 2019 14:58:35 +0800 Subject: [PATCH] =?UTF-8?q?ssl=20policy=E4=BD=BF=E7=94=A8gcc=20=5F=5Fsync?= =?UTF-8?q?=5Fadd=5Fand=5Ffetch=E6=93=8D=E4=BD=9C=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=EF=BC=8Cfix=20#150?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/business/ssl-policy/src/ssl_policy.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/business/ssl-policy/src/ssl_policy.cpp b/plugin/business/ssl-policy/src/ssl_policy.cpp index fb9dde7..cc9fe0f 100644 --- a/plugin/business/ssl-policy/src/ssl_policy.cpp +++ b/plugin/business/ssl-policy/src/ssl_policy.cpp @@ -38,14 +38,14 @@ struct intercept_param void intercept_param_dup_cb(int table_id, MAAT_PLUGIN_EX_DATA* to, MAAT_PLUGIN_EX_DATA* from, long argl, void* argp) { struct intercept_param* param= (struct intercept_param*) *from; - if(param==NULL) + if(param) { - *to=NULL; + __sync_add_and_fetch(&(param->ref_cnt), 1); + *to = param; } else { - param->ref_cnt++; - *to = param; + *to=NULL; } return; } @@ -171,8 +171,8 @@ void intercept_param_free_cb(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, v { return; } - param->ref_cnt--; - if(param->ref_cnt==0) + + if ((__sync_sub_and_fetch(¶m->ref_cnt, 1) == 0)) { TFE_LOG_INFO(enforcer->logger, "Del intercept policy %d", param->policy_id);\ free(param);