ssl policy使用gcc __sync_add_and_fetch操作引用计数,fix #150

This commit is contained in:
zhengchao
2019-06-21 14:58:35 +08:00
parent 251e40e588
commit ef9360fb3e

View File

@@ -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);