Mercurial > hg > nginx
diff src/event/modules/ngx_epoll_module.c @ 6542:c93e57ba301b
Events: close descriptors on errors in ngx_epoll_test_rdhup().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 18 May 2016 15:57:30 +0300 |
parents | 282448777dc2 |
children | 18f6120e3b7a |
line wrap: on
line diff
--- a/src/event/modules/ngx_epoll_module.c Wed May 18 15:57:29 2016 +0300 +++ b/src/event/modules/ngx_epoll_module.c Wed May 18 15:57:30 2016 +0300 @@ -477,25 +477,26 @@ if (epoll_ctl(ep, EPOLL_CTL_ADD, s[0], &ee) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, "epoll_ctl() failed"); - return; + goto failed; } if (close(s[1]) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, "close() failed"); - return; + s[1] = -1; + goto failed; } + s[1] = -1; + events = epoll_wait(ep, &ee, 1, 5000); if (events == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, "epoll_wait() failed"); - return; + goto failed; } - (void) close(s[0]); - if (events) { ngx_use_epoll_rdhup = ee.events & EPOLLRDHUP; @@ -507,6 +508,18 @@ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "testing the EPOLLRDHUP flag: %s", ngx_use_epoll_rdhup ? "success" : "fail"); + +failed: + + if (s[1] != -1 && close(s[1]) == -1) { + ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, + "close() failed"); + } + + if (close(s[0]) == -1) { + ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, + "close() failed"); + } } #endif