mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-30 02:47:56 +08:00
fixed one bug in events_kqueue.h for time interval computing
This commit is contained in:
parent
9b0c1cc233
commit
922784168d
@ -1,5 +1,8 @@
|
||||
修改历史列表:
|
||||
|
||||
660) 2019.8.9
|
||||
660,1) bugfix: events_kqueue.h 中时间间隔计算有误,导致时间间隔过长
|
||||
|
||||
659) 2019.8.2
|
||||
659.1) bugfix: acl_myloc.c 中的函数 init_log_mutex() 去掉 PTHREAD_MUTEX_RECURSIVE 宏
|
||||
的条件编译,可能会造成一些未知问题
|
||||
|
@ -87,8 +87,8 @@ typedef struct kevent EVENT_BUFFER;
|
||||
tsp = 0; \
|
||||
} else { \
|
||||
tsp = &ts; \
|
||||
ts.tv_nsec = 0; \
|
||||
ts.tv_sec = (delay); \
|
||||
ts.tv_nsec = ((delay) % 1000) * 1000000; \
|
||||
ts.tv_sec = (delay) / 1000; \
|
||||
} \
|
||||
(ev_cnt) = kevent(eh, (struct kevent *) 0, 0, (ev_buf), (buflen), (tsp)); \
|
||||
} while (0)
|
||||
|
@ -217,6 +217,9 @@ int main(int argc, char* argv[])
|
||||
// 定义 AIO 事件引擎
|
||||
acl::aio_handle handle(kernel_event ? acl::ENGINE_KERNEL : acl::ENGINE_POLL);
|
||||
|
||||
handle.set_delay_sec(0);
|
||||
handle.set_delay_usec(1000000);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 设置 DNS 域名服务器地址
|
||||
@ -254,12 +257,18 @@ int main(int argc, char* argv[])
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
time_t last = time(NULL), now;
|
||||
// 开始 AIO 事件循环过程
|
||||
while (true) {
|
||||
// 如果返回 false 则表示不再继续,需要退出
|
||||
if (!handle.check()) {
|
||||
break;
|
||||
}
|
||||
(void) time(&now);
|
||||
if (now - last > 0) {
|
||||
printf("continue check %ld seconds...\r\n", now - last);
|
||||
}
|
||||
last = now;
|
||||
}
|
||||
|
||||
handle.check();
|
||||
|
Loading…
Reference in New Issue
Block a user