增加udp的链接数统计
增加程序的健壮性
This commit is contained in:
@@ -48,7 +48,8 @@ char TSG_MASTER_VERSION_20200805=0;
|
|||||||
const char *tsg_conffile="tsgconf/main.conf";
|
const char *tsg_conffile="tsgconf/main.conf";
|
||||||
g_tsg_para_t g_tsg_para;
|
g_tsg_para_t g_tsg_para;
|
||||||
|
|
||||||
id2field_t g_tsg_fs2_field[TSG_FS2_MAX]={{TLD_TYPE_UNKNOWN, TSG_FS2_LINKS, "links"},
|
id2field_t g_tsg_fs2_field[TSG_FS2_MAX]={{TLD_TYPE_UNKNOWN, TSG_FS2_TCP_LINKS, "tcp_links"},
|
||||||
|
{TLD_TYPE_UNKNOWN, TSG_FS2_UDP_LINKS, "udp_links"},
|
||||||
{TLD_TYPE_UNKNOWN, TSG_FS2_BYPASS, "bypass"},
|
{TLD_TYPE_UNKNOWN, TSG_FS2_BYPASS, "bypass"},
|
||||||
{TLD_TYPE_UNKNOWN, TSG_FS2_HIT_ADDR, "hit_addr"},
|
{TLD_TYPE_UNKNOWN, TSG_FS2_HIT_ADDR, "hit_addr"},
|
||||||
{TLD_TYPE_UNKNOWN, TSG_FS2_HIT_SHARE, "hit_share"},
|
{TLD_TYPE_UNKNOWN, TSG_FS2_HIT_SHARE, "hit_share"},
|
||||||
@@ -665,7 +666,7 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
|
|||||||
switch(a_tcp->opstate)
|
switch(a_tcp->opstate)
|
||||||
{
|
{
|
||||||
case OP_STATE_PENDING:
|
case OP_STATE_PENDING:
|
||||||
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_LINKS], 0, FS_OP_ADD, 1);
|
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_TCP_LINKS], 0, FS_OP_ADD, 1);
|
||||||
|
|
||||||
internal_label=(struct _session_attribute_label_t *)dictator_malloc(1, sizeof(struct _session_attribute_label_t));
|
internal_label=(struct _session_attribute_label_t *)dictator_malloc(1, sizeof(struct _session_attribute_label_t));
|
||||||
memset(internal_label, 0, sizeof(struct _session_attribute_label_t));
|
memset(internal_label, 0, sizeof(struct _session_attribute_label_t));
|
||||||
@@ -867,6 +868,7 @@ extern "C" char TSG_MASTER_UDP_ENTRY(struct streaminfo *a_udp, void **pme, int t
|
|||||||
switch(a_udp->opstate)
|
switch(a_udp->opstate)
|
||||||
{
|
{
|
||||||
case OP_STATE_PENDING:
|
case OP_STATE_PENDING:
|
||||||
|
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_UDP_LINKS], 0, FS_OP_ADD, 1);
|
||||||
memset(&identify_info, 0, sizeof(identify_info));
|
memset(&identify_info, 0, sizeof(identify_info));
|
||||||
identify_application_protocol(a_udp, &identify_info, NULL, a_packet);
|
identify_application_protocol(a_udp, &identify_info, NULL, a_packet);
|
||||||
|
|
||||||
@@ -1124,7 +1126,7 @@ extern "C" int TSG_MASTER_INIT()
|
|||||||
|
|
||||||
for(i=0; i<TSG_FS2_MAX; i++)
|
for(i=0; i<TSG_FS2_MAX; i++)
|
||||||
{
|
{
|
||||||
g_tsg_para.fs2_field_id[g_tsg_fs2_field[i].id]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, g_tsg_fs2_field[i].name);
|
g_tsg_para.fs2_field_id[i]=FS_register(g_tsg_para.fs2_handle, FS_STYLE_FIELD, FS_CALC_SPEED, g_tsg_fs2_field[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
char buff[32]={0};
|
char buff[32]={0};
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ enum MASTER_TABLE{
|
|||||||
|
|
||||||
|
|
||||||
enum TSG_FS2_TYPE{
|
enum TSG_FS2_TYPE{
|
||||||
TSG_FS2_LINKS=0,
|
TSG_FS2_TCP_LINKS=0,
|
||||||
|
TSG_FS2_UDP_LINKS,
|
||||||
TSG_FS2_BYPASS,
|
TSG_FS2_BYPASS,
|
||||||
TSG_FS2_HIT_ADDR,
|
TSG_FS2_HIT_ADDR,
|
||||||
TSG_FS2_HIT_SHARE,
|
TSG_FS2_HIT_SHARE,
|
||||||
|
|||||||
@@ -625,7 +625,8 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
|
|||||||
"tsg same log:cfg_id=%d service=%d addr=%s",
|
"tsg same log:cfg_id=%d service=%d addr=%s",
|
||||||
log_msg->result[i].config_id,
|
log_msg->result[i].config_id,
|
||||||
log_msg->result[i].service_id,
|
log_msg->result[i].service_id,
|
||||||
printaddr(&(log_msg->a_stream->addr), thread_id));
|
(log_msg->a_stream==NULL ? "" : printaddr(&(log_msg->a_stream->addr), thread_id))
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,7 +640,8 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
|
|||||||
log_msg->result[i].config_id,
|
log_msg->result[i].config_id,
|
||||||
log_msg->result[i].service_id,
|
log_msg->result[i].service_id,
|
||||||
_instance->send_log_percent[thread_id],
|
_instance->send_log_percent[thread_id],
|
||||||
printaddr(&(log_msg->a_stream->addr), thread_id));
|
(log_msg->a_stream==NULL ? "" : printaddr(&(log_msg->a_stream->addr), thread_id))
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,11 +649,12 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
|
|||||||
{
|
{
|
||||||
case LOG_ABORT:
|
case LOG_ABORT:
|
||||||
MESA_handle_runtime_log(_instance->logger, RLOG_LV_INFO,
|
MESA_handle_runtime_log(_instance->logger, RLOG_LV_INFO,
|
||||||
"TSG_SEND_LOG",
|
"TSG_SEND_LOG",
|
||||||
"tsg abort log:cfg_id=%d service=%d addr=%s",
|
"tsg abort log:cfg_id=%d service=%d addr=%s",
|
||||||
log_msg->result[i].config_id,
|
log_msg->result[i].config_id,
|
||||||
log_msg->result[i].service_id,
|
log_msg->result[i].service_id,
|
||||||
printaddr(&(log_msg->a_stream->addr), thread_id));
|
(log_msg->a_stream==NULL ? "" : printaddr(&(log_msg->a_stream->addr), thread_id))
|
||||||
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
@@ -683,7 +686,7 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
|
|||||||
{
|
{
|
||||||
_instance->send_log_percent[thread_id]/=2;
|
_instance->send_log_percent[thread_id]/=2;
|
||||||
clock_gettime(CLOCK_REALTIME, &_instance->drop_start[thread_id]);
|
clock_gettime(CLOCK_REALTIME, &_instance->drop_start[thread_id]);
|
||||||
FS_operate(g_tsg_para.fs2_handle,_instance ->fs_status_ids[thread_id], 0, FS_OP_SET, _instance->send_log_percent[thread_id]);
|
FS_operate(g_tsg_para.fs2_handle, _instance->fs_status_ids[thread_id], 0, FS_OP_SET, _instance->send_log_percent[thread_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_FAILED_LOG], 0, FS_OP_ADD, 1);
|
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_FAILED_LOG], 0, FS_OP_ADD, 1);
|
||||||
@@ -707,7 +710,7 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
|
|||||||
payload
|
payload
|
||||||
);
|
);
|
||||||
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_SUCCESS_LOG], 0, FS_OP_ADD, 1);
|
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_SUCCESS_LOG], 0, FS_OP_ADD, 1);
|
||||||
FS_operate(g_tsg_para.fs2_handle,_instance ->fs_status_ids[thread_id], 0, FS_OP_SET, _instance->send_log_percent[thread_id]);
|
FS_operate(g_tsg_para.fs2_handle, _instance->fs_status_ids[thread_id], 0, FS_OP_SET, _instance->send_log_percent[thread_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(payload);
|
free(payload);
|
||||||
@@ -728,7 +731,7 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
|
|||||||
{
|
{
|
||||||
_instance->send_log_percent[thread_id]++;
|
_instance->send_log_percent[thread_id]++;
|
||||||
_instance->drop_start[thread_id].tv_sec=cur_time.tv_sec;
|
_instance->drop_start[thread_id].tv_sec=cur_time.tv_sec;
|
||||||
FS_operate(g_tsg_para.fs2_handle,_instance ->fs_status_ids[thread_id], 0, FS_OP_SET, _instance->send_log_percent[thread_id]);
|
FS_operate(g_tsg_para.fs2_handle, _instance->fs_status_ids[thread_id], 0, FS_OP_SET, _instance->send_log_percent[thread_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user