mirror of
https://github.com/wangyu-/UDPspeeder.git
synced 2025-01-31 12:19:35 +08:00
just commit
This commit is contained in:
parent
d5483d4984
commit
1a4149eef2
@ -170,6 +170,7 @@ int conv_manager_t::clear_inactive0(char * ip_port)
|
|||||||
}
|
}
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
|
clear_it=it;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ int conv_manager_t::clear_inactive0(char * ip_port)
|
|||||||
conn_manager_t::conn_manager_t()
|
conn_manager_t::conn_manager_t()
|
||||||
{
|
{
|
||||||
//ready_num=0;
|
//ready_num=0;
|
||||||
mp.reserve(100007);
|
mp.reserve(10007);
|
||||||
//fd64_mp.reserve(100007);
|
//fd64_mp.reserve(100007);
|
||||||
clear_it=mp.begin();
|
clear_it=mp.begin();
|
||||||
last_clear_time=0;
|
last_clear_time=0;
|
||||||
@ -280,6 +281,7 @@ int conn_manager_t::clear_inactive()
|
|||||||
}
|
}
|
||||||
int conn_manager_t::clear_inactive0()
|
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 it;
|
||||||
unordered_map<u64_t,conn_info_t*>::iterator old_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;
|
//map<uint32_t,uint64_t>::iterator it;
|
||||||
int cnt=0;
|
int cnt=0;
|
||||||
it=clear_it;
|
it=clear_it;//TODO,write it back
|
||||||
int size=mp.size();
|
int size=mp.size();
|
||||||
int num_to_clean=size/conn_clear_ratio+conn_clear_min; //clear 1/10 each time,to avoid latency glitch
|
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());
|
num_to_clean=min(num_to_clean,(int)mp.size());
|
||||||
u64_t current_time=get_current_time();
|
u64_t current_time=get_current_time();
|
||||||
|
|
||||||
|
mylog(log_info,"here size=%d\n",(int)mp.size());
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if(cnt>=num_to_clean) break;
|
if(cnt>=num_to_clean) break;
|
||||||
if(mp.begin()==mp.end()) break;
|
if(mp.begin()==mp.end()) break;
|
||||||
|
|
||||||
if(it==mp.end())
|
if(it==mp.end())
|
||||||
{
|
{
|
||||||
it=mp.begin();
|
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++;
|
it++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -319,6 +322,7 @@ int conn_manager_t::clear_inactive0()
|
|||||||
}
|
}
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
|
clear_it=it;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +117,10 @@ struct delay_manager_t
|
|||||||
int capacity;
|
int capacity;
|
||||||
multimap<my_time_t,delay_data_t> delay_mp; //unit us,1 us=0.001ms
|
multimap<my_time_t,delay_data_t> delay_mp; //unit us,1 us=0.001ms
|
||||||
delay_manager_t();
|
delay_manager_t();
|
||||||
|
delay_manager_t(delay_manager_t &b)
|
||||||
|
{
|
||||||
|
assert(0==1);
|
||||||
|
}
|
||||||
~delay_manager_t();
|
~delay_manager_t();
|
||||||
int get_timer_fd();
|
int get_timer_fd();
|
||||||
int check();
|
int check();
|
||||||
|
10
main.cpp
10
main.cpp
@ -442,6 +442,9 @@ int client_event_loop()
|
|||||||
if(get_conv(conv,out_arr[i],out_len[i],new_data,new_len)!=0)
|
if(get_conv(conv,out_arr[i],out_len[i],new_data,new_len)!=0)
|
||||||
continue;
|
continue;
|
||||||
if(!conn_info.conv_manager.is_conv_used(conv))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);
|
u64_t u64=conn_info.conv_manager.find_u64_by_conv(conv);
|
||||||
dest_t dest;
|
dest_t dest;
|
||||||
dest.inner.ip_port.from_u64(u64);
|
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();
|
u64_t timer_fd64=conn_info.timer.get_timer_fd64();
|
||||||
fd_manager.get_info(timer_fd64).ip_port=ip_port;
|
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);
|
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);
|
conn_info.conv_manager.insert_conv(conv, fd64);
|
||||||
fd_manager.get_info(fd64).ip_port=ip_port;
|
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));
|
//assert(!conn_manager.exist_fd64(fd64));
|
||||||
|
|
||||||
//conn_manager.insert_fd64(fd64,ip_port);
|
//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);
|
fd64_t fd64= conn_info.conv_manager.find_u64_by_conv(conv);
|
||||||
//int fd=fd_manager.fd64_to_fd(fd64);
|
//int fd=fd_manager.fd64_to_fd(fd64);
|
||||||
dest_t dest;
|
dest_t dest;
|
||||||
@ -755,6 +764,7 @@ int server_event_loop()
|
|||||||
assert(conn_info.conv_manager.is_u64_used(fd64));
|
assert(conn_info.conv_manager.is_u64_used(fd64));
|
||||||
|
|
||||||
conv=conn_info.conv_manager.find_conv_by_u64(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);
|
int fd=fd_manager.to_fd(fd64);
|
||||||
data_len=recv(fd,data,max_data_len,0);
|
data_len=recv(fd,data,max_data_len,0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user