From 67e6bd0470aefc45078904d634c71d32ad1e597f Mon Sep 17 00:00:00 2001 From: ubuntu14 Date: Mon, 21 Dec 2015 23:53:55 +0800 Subject: [PATCH] fixed one urgent bug in acl_read_wait --- app/wizard/changes.txt | 4 ++++ app/wizard/tmpl/http/master_threads.cpp | 2 +- app/wizard/tmpl/master/master_threads.cpp | 2 +- changes.txt | 1 + lib_acl/changes.txt | 1 + lib_acl/src/init/acl_init.c | 2 +- lib_acl/src/stdlib/iostuff/acl_read_wait.c | 12 ++++++------ 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/wizard/changes.txt b/app/wizard/changes.txt index 4e5e91e38..85dcdc9c7 100644 --- a/app/wizard/changes.txt +++ b/app/wizard/changes.txt @@ -1,3 +1,7 @@ +9) 2015.12.21 +9.1) bugfix: master_threads.cpp 中的函数 proc_exit_timer 在只有当 nclients 为0 +时才允许退出 + 8) 2015.6.22 8.1) comment: 向导生成的服务器工程中的 main 源程序中增加了注释,指明使用方法 diff --git a/app/wizard/tmpl/http/master_threads.cpp b/app/wizard/tmpl/http/master_threads.cpp index e310d547a..0540c9cce 100644 --- a/app/wizard/tmpl/http/master_threads.cpp +++ b/app/wizard/tmpl/http/master_threads.cpp @@ -115,7 +115,7 @@ void master_service::proc_on_exit() bool master_service::proc_exit_timer(size_t nclients, size_t nthreads) { - if (nclients == 0 || nthreads == 0) + if (nclients == 0) { logger("clients count: %d, threads count: %d", (int) nclients, (int) nthreads); diff --git a/app/wizard/tmpl/master/master_threads.cpp b/app/wizard/tmpl/master/master_threads.cpp index 558fc44fe..d9f60f73b 100644 --- a/app/wizard/tmpl/master/master_threads.cpp +++ b/app/wizard/tmpl/master/master_threads.cpp @@ -95,7 +95,7 @@ void master_service::proc_on_init() bool master_service::proc_exit_timer(size_t nclients, size_t nthreads) { - if (nclients == 0 || nthreads == 0) + if (nclients == 0) { logger("clients count: %d, threads count: %d", (int) nclients, (int) nthreads); diff --git a/changes.txt b/changes.txt index b713f4ca5..beb679a96 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ 修改历史列表: ------------------------------------------------------------------------ +92) 2015.12.21 --- acl 3.1.4.2 版本发布!(修复了一处紧急 BUG) 91) 2015.12.21 --- acl 3.1.4.1 版本发布!(修复了几处紧急 BUG) 90) 2015.12.20 --- acl 3.1.4 版本发布! 89) 2015.11.4 diff --git a/lib_acl/changes.txt b/lib_acl/changes.txt index 50151454e..610da185c 100644 --- a/lib_acl/changes.txt +++ b/lib_acl/changes.txt @@ -6,6 +6,7 @@ 调用系统 API read,否则会形成死循环 520.2) bugfix: event 事件引擎应该区分监听描述字和一般套接字,有的地方未给 监听套接字 listener 置 1,这样会造成死循环 +520.3) bugfix: acl_read_wait 函数中使用 epoll 的方式有问题,会造成死循环 519) 2015.12.20 519.1) feature: acl_aio.c 增加了设置检查所有套接字状态的时间间隔函数 diff --git a/lib_acl/src/init/acl_init.c b/lib_acl/src/init/acl_init.c index 47041e400..8e515e658 100644 --- a/lib_acl/src/init/acl_init.c +++ b/lib_acl/src/init/acl_init.c @@ -24,7 +24,7 @@ #include "init.h" -static char *version = "acl_3.1.4"; +static char *version = "acl_3.1.4.2"; const char *acl_version(void) { diff --git a/lib_acl/src/stdlib/iostuff/acl_read_wait.c b/lib_acl/src/stdlib/iostuff/acl_read_wait.c index a7fe7d78d..98d01c2a3 100644 --- a/lib_acl/src/stdlib/iostuff/acl_read_wait.c +++ b/lib_acl/src/stdlib/iostuff/acl_read_wait.c @@ -87,10 +87,10 @@ int acl_read_wait(ACL_SOCKET fd, int timeout) } for (;;) { - switch (epoll_wait(*epoll_fd, events, 1, delay)) { - case -1: - if (acl_last_error() == ACL_EINTR) - { + ret = epoll_wait(*epoll_fd, events, 1, delay); + + if (ret == -1) { + if (acl_last_error() == ACL_EINTR) { acl_msg_warn(">>>>catch EINTR, try again<<<"); continue; } @@ -99,11 +99,11 @@ int acl_read_wait(ACL_SOCKET fd, int timeout) myname, __LINE__, acl_last_serror(), fd); ret = -1; break; - case 0: + } else if (ret == 0) { acl_set_error(ACL_ETIMEDOUT); ret = -1; break; - default: + } else { if ((events[0].events & (EPOLLERR | EPOLLHUP)) != 0) ret = -1; else if ((events[0].events & EPOLLIN) == 0) {