fix test, fix core

This commit is contained in:
wangyu- 2018-06-04 02:59:08 -05:00
parent d355031613
commit 8827c8469c
6 changed files with 41 additions and 6 deletions

View File

@ -237,8 +237,11 @@ int conn_manager_t::exist(ip_port_t ip_port)
int conn_manager_t::erase(unordered_map<u64_t,conn_info_t*>::iterator erase_it)
{
////////todo close and erase timer_fd ,check fd64 empty ///dont need
delete(erase_it->second);
mp.erase(erase_it->first);
return 0;
}
int conn_manager_t::clear_inactive()

View File

@ -112,7 +112,7 @@ struct conn_info_t //stores info for a raw connection.for client ,there is o
u64_t last_active_time;
stat_t stat;
ev_loop* loop;
ev_loop* loop=0;
int local_listen_fd;
int remote_fd; //only used for client
@ -123,6 +123,12 @@ struct conn_info_t //stores info for a raw connection.for client ,there is o
conn_info_t()
{
}
~conn_info_t()
{
if(loop)
ev_timer_stop(loop,&timer);
}
void update_active_time()
{
last_active_time=get_current_time();

View File

@ -131,7 +131,7 @@ int blob_decode_t::output(int &n,char ** &s_arr,int *&len_arr)
fec_encode_manager_t::~fec_encode_manager_t()
{
clear();
clear_all();
//fd_manager.fd64_close(timer_fd64);
}
/*
@ -168,8 +168,9 @@ int fec_encode_manager_t::reset_fec_parameter(int data_num,int redundant_num,int
assert(data_num+redundant_num<max_fec_packet_num);
clear();
//clear();
clear_data();
return 0;
}
int fec_encode_manager_t::append(char *s,int len/*,int &is_first_packet*/)

View File

@ -163,12 +163,23 @@ public:
ev_init(&timer,cb);
}
int clear()
int clear_data()
{
counter=0;
blob_encode.clear();
ready_for_output=0;
seq=(u32_t)get_fake_random_number(); //TODO temp solution for a bug.
if(loop)
{
ev_timer_stop(loop,&timer);
}
return 0;
}
int clear_all()
{
//itimerspec zero_its;
//memset(&zero_its, 0, sizeof(zero_its));
//timerfd_settime(timer_fd, TFD_TIMER_ABSTIME, &zero_its, 0);
@ -179,7 +190,8 @@ public:
loop=0;
cb=0;
}
seq=(u32_t)get_fake_random_number(); //TODO temp solution for a bug.
clear_data();
return 0;
}

View File

@ -328,6 +328,10 @@ int handle_command(char *s)
return 0;
}
static void empty_cb(struct ev_loop *loop, struct ev_timer *watcher, int revents)
{
}
int unit_test()
{
@ -435,6 +439,10 @@ int unit_test()
static fec_encode_manager_t fec_encode_manager;
static fec_decode_manager_t fec_decode_manager;
dynamic_update_fec=0;
fec_encode_manager.set_loop_and_cb(ev_default_loop(0),empty_cb);
{
string a = "11111";
@ -510,6 +518,7 @@ int unit_test()
}
}
printf("ok here.\n");
for(int i=0;i<10;i++)
{
string a = "aaaaaaaaaaaaaaaaaaaaaaa";
@ -528,6 +537,8 @@ int unit_test()
fec_encode_manager.input((char *) a.c_str(), a.length());
fec_encode_manager.output(n,s_arr,len);
printf("n=<%d>\n",n);
assert(n==1);
fec_decode_manager.input(s_arr[0],len[0]);
@ -575,7 +586,7 @@ int unit_test()
}
myexit(0);
return 0;
}

View File

@ -277,6 +277,8 @@ int tunnel_client_event_loop()
struct ev_loop * loop= ev_default_loop(0);
assert(loop != NULL);
conn_info.loop=loop;
//ev.events = EPOLLIN;
//ev.data.u64 = local_listen_fd;
//ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, local_listen_fd, &ev);