mirror of
https://github.com/wangyu-/UDPspeeder.git
synced 2025-01-31 12:19:35 +08:00
fixed conn clear bug
This commit is contained in:
parent
321afdb627
commit
4ab16d096a
2
common.h
2
common.h
@ -105,7 +105,7 @@ const u32_t client_conn_timeout=10000;
|
|||||||
const u32_t client_conn_uplink_timeout=client_conn_timeout+2000;
|
const u32_t client_conn_uplink_timeout=client_conn_timeout+2000;
|
||||||
|
|
||||||
//const uint32_t server_conn_timeout=conv_timeout+60000;//this should be 60s+ longer than conv_timeout,so that conv_manager can destruct convs gradually,to avoid latency glicth
|
//const uint32_t server_conn_timeout=conv_timeout+60000;//this should be 60s+ longer than conv_timeout,so that conv_manager can destruct convs gradually,to avoid latency glicth
|
||||||
const u32_t server_conn_timeout=conv_timeout+60000;//for test
|
const u32_t server_conn_timeout=conv_timeout+20000;//for test
|
||||||
|
|
||||||
|
|
||||||
extern int about_to_exit;
|
extern int about_to_exit;
|
||||||
|
@ -313,6 +313,10 @@ int conn_manager_t::clear_inactive0()
|
|||||||
//mylog(log_info,"[%s:%d]size %d \n",my_ntoa(get_u64_h(it->first)),get_u64_l(it->first),(int)it->second->conv_manager.get_size());
|
//mylog(log_info,"[%s:%d]size %d \n",my_ntoa(get_u64_h(it->first)),get_u64_l(it->first),(int)it->second->conv_manager.get_size());
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
else if(current_time<it->second->last_active_time+server_conn_timeout)
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mylog(log_info,"[%s:%d]inactive conn cleared \n",my_ntoa(get_u64_h(it->first)),get_u64_l(it->first));
|
mylog(log_info,"[%s:%d]inactive conn cleared \n",my_ntoa(get_u64_h(it->first)),get_u64_l(it->first));
|
||||||
|
@ -76,9 +76,14 @@ struct conn_info_t //stores info for a raw connection.for client ,there is o
|
|||||||
fec_decode_manager_t fec_decode_manager;
|
fec_decode_manager_t fec_decode_manager;
|
||||||
my_timer_t timer;
|
my_timer_t timer;
|
||||||
ip_port_t ip_port;
|
ip_port_t ip_port;
|
||||||
|
u64_t last_active_time;
|
||||||
conn_info_t()
|
conn_info_t()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void update_active_time()
|
||||||
|
{
|
||||||
|
last_active_time=get_current_time();
|
||||||
|
}
|
||||||
conn_info_t(const conn_info_t &b)
|
conn_info_t(const conn_info_t &b)
|
||||||
{
|
{
|
||||||
assert(0==1);
|
assert(0==1);
|
||||||
|
@ -252,7 +252,7 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
mylog(log_info,"%d %d %d\n",actual_data_num,actual_redundant_num,fec_len);
|
mylog(log_trace,"%d %d %d\n",actual_data_num,actual_redundant_num,fec_len);
|
||||||
|
|
||||||
char *tmp_output_buf[max_fec_packet_num+5]={0};
|
char *tmp_output_buf[max_fec_packet_num+5]={0};
|
||||||
for(int i=0;i<actual_data_num+actual_redundant_num;i++)
|
for(int i=0;i<actual_data_num+actual_redundant_num;i++)
|
||||||
@ -301,7 +301,7 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/)
|
|||||||
//output_len=blob_len+sizeof(u32_t)+4*sizeof(char);/////remember to change this 4,if modified the protocol
|
//output_len=blob_len+sizeof(u32_t)+4*sizeof(char);/////remember to change this 4,if modified the protocol
|
||||||
rs_encode2(actual_data_num,actual_data_num+actual_redundant_num,tmp_output_buf,fec_len);
|
rs_encode2(actual_data_num,actual_data_num+actual_redundant_num,tmp_output_buf,fec_len);
|
||||||
|
|
||||||
mylog(log_info,"!!! s= %d\n");
|
mylog(log_trace,"!!! s= %d\n");
|
||||||
|
|
||||||
ready_for_output=1;
|
ready_for_output=1;
|
||||||
seq++;
|
seq++;
|
||||||
@ -412,7 +412,7 @@ int fec_decode_manager_t::input(char *s,int len)
|
|||||||
int inner_index=(unsigned char)s[tmp_idx++];
|
int inner_index=(unsigned char)s[tmp_idx++];
|
||||||
len=len-tmp_idx;
|
len=len-tmp_idx;
|
||||||
|
|
||||||
mylog(log_info,"input\n");
|
mylog(log_trace,"input\n");
|
||||||
if(len<0)
|
if(len<0)
|
||||||
{
|
{
|
||||||
mylog(log_warn,"len<0\n");
|
mylog(log_warn,"len<0\n");
|
||||||
|
6
main.cpp
6
main.cpp
@ -553,7 +553,7 @@ int server_event_loop()
|
|||||||
{
|
{
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
read(timer.get_timer_fd(), &value, 8);
|
read(timer.get_timer_fd(), &value, 8);
|
||||||
///conn_manager.clear_inactive();///////////////////////////remember to uncomment
|
conn_manager.clear_inactive();
|
||||||
//conn_info.conv_manager.clear_inactive();
|
//conn_info.conv_manager.clear_inactive();
|
||||||
}
|
}
|
||||||
else if (events[idx].data.u64 == (u64_t)local_listen_fd)
|
else if (events[idx].data.u64 == (u64_t)local_listen_fd)
|
||||||
@ -611,10 +611,11 @@ int server_event_loop()
|
|||||||
}
|
}
|
||||||
conn_info_t &conn_info=conn_manager.find(ip_port);
|
conn_info_t &conn_info=conn_manager.find(ip_port);
|
||||||
|
|
||||||
|
conn_info.update_active_time();
|
||||||
int out_n;char **out_arr;int *out_len;int *out_delay;
|
int out_n;char **out_arr;int *out_len;int *out_delay;
|
||||||
from_fec_to_normal(conn_info,data,data_len,out_n,out_arr,out_len,out_delay);
|
from_fec_to_normal(conn_info,data,data_len,out_n,out_arr,out_len,out_delay);
|
||||||
|
|
||||||
mylog(log_info,"out_n= %d\n",out_n);
|
mylog(log_trace,"out_n= %d\n",out_n);
|
||||||
for(int i=0;i<out_n;i++)
|
for(int i=0;i<out_n;i++)
|
||||||
{
|
{
|
||||||
u32_t conv;
|
u32_t conv;
|
||||||
@ -727,6 +728,7 @@ int server_event_loop()
|
|||||||
//conn_info_t* p_conn_info=conn_manager.find_insert_p(ip_port);
|
//conn_info_t* p_conn_info=conn_manager.find_insert_p(ip_port);
|
||||||
|
|
||||||
conn_info_t &conn_info=conn_manager.find(ip_port);
|
conn_info_t &conn_info=conn_manager.find(ip_port);
|
||||||
|
conn_info.update_active_time();
|
||||||
|
|
||||||
int out_n;char **out_arr;int *out_len;int *out_delay;
|
int out_n;char **out_arr;int *out_len;int *out_delay;
|
||||||
dest_t dest;
|
dest_t dest;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user