just commit

This commit is contained in:
wangyu- 2017-10-08 09:38:41 -05:00
parent d5483d4984
commit 1a4149eef2
3 changed files with 22 additions and 4 deletions

View File

@ -170,6 +170,7 @@ int conv_manager_t::clear_inactive0(char * ip_port)
}
cnt++;
}
clear_it=it;
return 0;
}
@ -178,7 +179,7 @@ int conv_manager_t::clear_inactive0(char * ip_port)
conn_manager_t::conn_manager_t()
{
//ready_num=0;
mp.reserve(100007);
mp.reserve(10007);
//fd64_mp.reserve(100007);
clear_it=mp.begin();
last_clear_time=0;
@ -280,6 +281,7 @@ int conn_manager_t::clear_inactive()
}
int conn_manager_t::clear_inactive0()
{
mylog(log_info,"called\n");
unordered_map<u64_t,conn_info_t*>::iterator it;
unordered_map<u64_t,conn_info_t*>::iterator old_it;
@ -287,7 +289,7 @@ int conn_manager_t::clear_inactive0()
//map<uint32_t,uint64_t>::iterator it;
int cnt=0;
it=clear_it;
it=clear_it;//TODO,write it back
int size=mp.size();
int num_to_clean=size/conn_clear_ratio+conn_clear_min; //clear 1/10 each time,to avoid latency glitch
@ -296,18 +298,19 @@ int conn_manager_t::clear_inactive0()
num_to_clean=min(num_to_clean,(int)mp.size());
u64_t current_time=get_current_time();
mylog(log_info,"here size=%d\n",(int)mp.size());
for(;;)
{
if(cnt>=num_to_clean) break;
if(mp.begin()==mp.end()) break;
if(it==mp.end())
{
it=mp.begin();
}
else if(it->second->conv_manager.get_size() >0)
if(it->second->conv_manager.get_size() >0)
{
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
@ -319,6 +322,7 @@ int conn_manager_t::clear_inactive0()
}
cnt++;
}
clear_it=it;
return 0;
}

View File

@ -117,6 +117,10 @@ struct delay_manager_t
int capacity;
multimap<my_time_t,delay_data_t> delay_mp; //unit us,1 us=0.001ms
delay_manager_t();
delay_manager_t(delay_manager_t &b)
{
assert(0==1);
}
~delay_manager_t();
int get_timer_fd();
int check();

View File

@ -442,6 +442,9 @@ int client_event_loop()
if(get_conv(conv,out_arr[i],out_len[i],new_data,new_len)!=0)
continue;
if(!conn_info.conv_manager.is_conv_used(conv))continue;
conn_info.conv_manager.update_active_time(conv);
u64_t u64=conn_info.conv_manager.find_u64_by_conv(conv);
dest_t dest;
dest.inner.ip_port.from_u64(u64);
@ -605,6 +608,8 @@ int server_event_loop()
u64_t timer_fd64=conn_info.timer.get_timer_fd64();
fd_manager.get_info(timer_fd64).ip_port=ip_port;
mylog(log_info,"new connection from %s\n",ip_port.to_s());
}
conn_info_t &conn_info=conn_manager.find(ip_port);
@ -641,10 +646,14 @@ int server_event_loop()
conn_info.conv_manager.insert_conv(conv, fd64);
fd_manager.get_info(fd64).ip_port=ip_port;
mylog(log_info,"[%s]new conv %x,fd %d created\n",ip_port.to_s(),conv,new_udp_fd);
//assert(!conn_manager.exist_fd64(fd64));
//conn_manager.insert_fd64(fd64,ip_port);
}
conn_info.conv_manager.update_active_time(conv);
fd64_t fd64= conn_info.conv_manager.find_u64_by_conv(conv);
//int fd=fd_manager.fd64_to_fd(fd64);
dest_t dest;
@ -755,6 +764,7 @@ int server_event_loop()
assert(conn_info.conv_manager.is_u64_used(fd64));
conv=conn_info.conv_manager.find_conv_by_u64(fd64);
conn_info.conv_manager.update_active_time(conv);
int fd=fd_manager.to_fd(fd64);
data_len=recv(fd,data,max_data_len,0);