summaryrefslogtreecommitdiff
path: root/plugin/business/ssl-policy/src/ssl_policy.cpp
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2019-06-21 14:58:35 +0800
committerzhengchao <[email protected]>2019-06-21 14:58:35 +0800
commitef9360fb3eab4edc8aa9d81be9ae3f9539623ee6 (patch)
treefa6e88823737d85b18fa5f2f4199fe02cb730941 /plugin/business/ssl-policy/src/ssl_policy.cpp
parent251e40e588170f2b087897021af50fb73a1f7748 (diff)
ssl policy使用gcc __sync_add_and_fetch操作引用计数,fix #150
Diffstat (limited to 'plugin/business/ssl-policy/src/ssl_policy.cpp')
-rw-r--r--plugin/business/ssl-policy/src/ssl_policy.cpp12
1 files 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(&param->ref_cnt, 1) == 0))
{
TFE_LOG_INFO(enforcer->logger, "Del intercept policy %d", param->policy_id);\
free(param);