From a54a0e269b2bb5857da869a89086878135cee2c8 Mon Sep 17 00:00:00 2001 From: wangyu- Date: Mon, 30 Oct 2017 08:19:21 -0500 Subject: [PATCH] fix timer of fd64 --- main.cpp | 6 +++--- misc.cpp | 6 ++++-- misc.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index aa765c3..15148c0 100755 --- a/main.cpp +++ b/main.cpp @@ -926,8 +926,7 @@ int server_on_raw_recv_pre_ready(conn_info_t &conn_info,char * ip_port,u32_t tmp //g_conn_info=conn_info; int new_timer_fd; - set_timer_server(epollfd, new_timer_fd); - conn_info.timer_fd64=fd_manager.create(new_timer_fd); + set_timer_server(epollfd, new_timer_fd,conn_info.timer_fd64); fd_manager.get_info(conn_info.timer_fd64).ip_port=conn_info.ip_port; //assert(conn_manager.timer_fd_mp.find(new_timer_fd)==conn_manager.timer_fd_mp.end()); @@ -1509,7 +1508,8 @@ int server_event_loop() { if(debug_flag)begin_time=get_current_time(); - int fd=get_u64_l(events[idx].data.u64); + //int fd=get_u64_l(events[idx].data.u64); + int fd=fd_manager.to_fd(fd64); u64_t dummy; read(fd, &dummy, 8); diff --git a/misc.cpp b/misc.cpp index 80c495a..033c33c 100644 --- a/misc.cpp +++ b/misc.cpp @@ -951,7 +951,7 @@ int set_timer(int epollfd,int &timer_fd)//put a timer_fd into epoll,general func } -int set_timer_server(int epollfd,int &timer_fd)//only for server +int set_timer_server(int epollfd,int &timer_fd,fd64_t &fd64)//only for server { int ret; epoll_event ev; @@ -969,9 +969,11 @@ int set_timer_server(int epollfd,int &timer_fd)//only for server its.it_value.tv_nsec=1; //imidiately timerfd_settime(timer_fd,0,&its,0); + fd64=fd_manager.create(timer_fd); + ev.events = EPOLLIN; - ev.data.u64 = pack_u64(2,timer_fd);////difference + ev.data.u64 = fd64;////difference ret=epoll_ctl(epollfd, EPOLL_CTL_ADD, timer_fd, &ev); if (ret < 0) { diff --git a/misc.h b/misc.h index b14c876..2049d3e 100644 --- a/misc.h +++ b/misc.h @@ -112,7 +112,7 @@ void iptables_rule(); void pre_process_arg(int argc, char *argv[]);//mainly for load conf file; int unit_test(); int set_timer(int epollfd,int &timer_fd); -int set_timer_server(int epollfd,int &timer_fd); +int set_timer_server(int epollfd,int &timer_fd,fd64_t &fd64); int handle_lower_level(raw_info_t &raw_info); int add_iptables_rule(const char *);