fixed conn clear bug

This commit is contained in:
wangyu- 2017-10-11 11:33:56 -05:00
parent 321afdb627
commit 4ab16d096a
5 changed files with 17 additions and 6 deletions

View File

@ -105,7 +105,7 @@ const u32_t client_conn_timeout=10000;
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 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;

View File

@ -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());
it++;
}
else if(current_time<it->second->last_active_time+server_conn_timeout)
{
it++;
}
else
{
mylog(log_info,"[%s:%d]inactive conn cleared \n",my_ntoa(get_u64_h(it->first)),get_u64_l(it->first));

View File

@ -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;
my_timer_t timer;
ip_port_t ip_port;
u64_t last_active_time;
conn_info_t()
{
}
void update_active_time()
{
last_active_time=get_current_time();
}
conn_info_t(const conn_info_t &b)
{
assert(0==1);

View File

@ -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};
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
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;
seq++;
@ -412,7 +412,7 @@ int fec_decode_manager_t::input(char *s,int len)
int inner_index=(unsigned char)s[tmp_idx++];
len=len-tmp_idx;
mylog(log_info,"input\n");
mylog(log_trace,"input\n");
if(len<0)
{
mylog(log_warn,"len<0\n");

View File

@ -553,7 +553,7 @@ int server_event_loop()
{
uint64_t value;
read(timer.get_timer_fd(), &value, 8);
///conn_manager.clear_inactive();///////////////////////////remember to uncomment
conn_manager.clear_inactive();
//conn_info.conv_manager.clear_inactive();
}
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.update_active_time();
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);
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++)
{
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 &conn_info=conn_manager.find(ip_port);
conn_info.update_active_time();
int out_n;char **out_arr;int *out_len;int *out_delay;
dest_t dest;