diff --git a/lib_acl/changes.txt b/lib_acl/changes.txt index 977786afb..6de1363f8 100644 --- a/lib_acl/changes.txt +++ b/lib_acl/changes.txt @@ -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 宏 的条件编译,可能会造成一些未知问题 diff --git a/lib_acl/src/event/events_kqueue.h b/lib_acl/src/event/events_kqueue.h index 5344f9bd6..f8e8add61 100644 --- a/lib_acl/src/event/events_kqueue.h +++ b/lib_acl/src/event/events_kqueue.h @@ -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) diff --git a/lib_acl_cpp/samples/aio/http_client/main.cpp b/lib_acl_cpp/samples/aio/http_client/main.cpp index a9c0cec2c..234dea3d6 100644 --- a/lib_acl_cpp/samples/aio/http_client/main.cpp +++ b/lib_acl_cpp/samples/aio/http_client/main.cpp @@ -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();