Fix screwup, fixes #137

1.修复HTTP2压缩段错误
2.修改发送无效的9字节DATA帧
3.对manipulate_profile结构多线程调用加锁处理
This commit is contained in:
fengweihao
2019-06-08 10:57:49 +08:00
parent 0eea8bd2a2
commit 814d5b4a30
3 changed files with 36 additions and 15 deletions

View File

@@ -97,7 +97,8 @@ struct manipulate_profile
char *profile_name;
char *profile_msg;
char *profile_type;
ctemplate::Template * tpl;
ctemplate::Template * tpl;
pthread_mutex_t lock;
};
struct policy_action_param
@@ -638,7 +639,9 @@ void ma_profile_table_new_cb(int table_id, const char* key, const char* table_li
memset(ply_profile, 0, sizeof(struct manipulate_profile));
ply_profile->profile_id=profile_id;
ply_profile->ref_cnt=1;
ply_profile->ref_cnt=1;
pthread_mutex_init(&(ply_profile->lock), NULL);
if(strcasecmp(formate, "template") == 0)
{
ply_profile->tpl = ctemplate::Template::GetTemplate(profile_path, ctemplate::DO_NOT_STRIP);
@@ -672,7 +675,8 @@ void ma_hijack_profile_table_new_cb(int table_id, const char* key, const char* t
return;
}
struct manipulate_profile* ply_profile=ALLOC(struct manipulate_profile, 1);
ply_profile->ref_cnt=1;
ply_profile->ref_cnt=1;
pthread_mutex_init(&(ply_profile->lock), NULL);
ply_profile->profile_id=profile_id;
ply_profile->profile_msg=tfe_strdup(profile_path);
@@ -687,17 +691,27 @@ void ma_hijack_profile_table_new_cb(int table_id, const char* key, const char* t
void ma_profile_table_free_cb(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void *argp)
{
struct manipulate_profile* ply_obj=(struct manipulate_profile*)(*ad);
ply_obj->ref_cnt--;
if (ply_obj->ref_cnt==0)
if(*ad==NULL)
{
FREE(&ply_obj->profile_type);
FREE(&ply_obj->profile_msg);
FREE(&ply_obj->profile_name);
FREE(&ply_obj);
*ad=NULL;
return;
}
struct manipulate_profile* ply_obj=(struct manipulate_profile*)(*ad);
pthread_mutex_lock(&(ply_obj->lock));
ply_obj->ref_cnt--;
if(ply_obj->ref_cnt>0)
{
pthread_mutex_unlock(&(ply_obj->lock));
return;
}
pthread_mutex_unlock(&(ply_obj->lock));
pthread_mutex_destroy(&(ply_obj->lock));
FREE(&ply_obj->profile_type);
FREE(&ply_obj->profile_msg);
FREE(&ply_obj->profile_name);
FREE(&ply_obj);
*ad=NULL;
return;
}
void ma_profile_table_free(struct manipulate_profile* ply_obj)
@@ -708,7 +722,9 @@ void ma_profile_table_free(struct manipulate_profile* ply_obj)
void ma_profile_table_dup_cb(int table_id, MAAT_PLUGIN_EX_DATA *to, MAAT_PLUGIN_EX_DATA *from, long argl, void *argp)
{
struct manipulate_profile* ply_obj=(struct manipulate_profile*)(*from);
pthread_mutex_lock(&(ply_obj->lock));
ply_obj->ref_cnt++;
pthread_mutex_unlock(&(ply_obj->lock));
*to=ply_obj;
}
@@ -1566,7 +1582,7 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
struct manipulate_profile* hijack_profile=get_profile_by_id(POLICY_PROFILE_TABLE_HIJACK, param->profile_id);
if (NULL == hijack_profile)
{
TFE_LOG_ERROR(g_pangu_rt->local_logger, "get table obj faild, table_id = %d", param->profile_id);
TFE_LOG_ERROR(g_pangu_rt->local_logger, "get table obj faild, profile_id = %d", param->profile_id);
ctx->action = PG_ACTION_NONE;
return;
}