Fixed work with --test-build-epoll after f7849bfb6d21.
This commit is contained in:
parent
bdff3e7a5a
commit
cbc94b5b3b
1 changed files with 70 additions and 66 deletions
|
@ -105,6 +105,9 @@ static ngx_int_t ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer);
|
||||||
static ngx_int_t ngx_epoll_notify_init(ngx_log_t *log);
|
static ngx_int_t ngx_epoll_notify_init(ngx_log_t *log);
|
||||||
static void ngx_epoll_notify_handler(ngx_event_t *ev);
|
static void ngx_epoll_notify_handler(ngx_event_t *ev);
|
||||||
#endif
|
#endif
|
||||||
|
#if (NGX_HAVE_EPOLLRDHUP)
|
||||||
|
static void ngx_epoll_test_rdhup(ngx_cycle_t *cycle);
|
||||||
|
#endif
|
||||||
static void ngx_epoll_done(ngx_cycle_t *cycle);
|
static void ngx_epoll_done(ngx_cycle_t *cycle);
|
||||||
static ngx_int_t ngx_epoll_add_event(ngx_event_t *ev, ngx_int_t event,
|
static ngx_int_t ngx_epoll_add_event(ngx_event_t *ev, ngx_int_t event,
|
||||||
ngx_uint_t flags);
|
ngx_uint_t flags);
|
||||||
|
@ -123,7 +126,6 @@ static ngx_int_t ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
|
||||||
static void ngx_epoll_eventfd_handler(ngx_event_t *ev);
|
static void ngx_epoll_eventfd_handler(ngx_event_t *ev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ngx_int_t ngx_epoll_module_init(ngx_cycle_t *cycle);
|
|
||||||
static void *ngx_epoll_create_conf(ngx_cycle_t *cycle);
|
static void *ngx_epoll_create_conf(ngx_cycle_t *cycle);
|
||||||
static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf);
|
static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf);
|
||||||
|
|
||||||
|
@ -202,7 +204,7 @@ ngx_module_t ngx_epoll_module = {
|
||||||
ngx_epoll_commands, /* module directives */
|
ngx_epoll_commands, /* module directives */
|
||||||
NGX_EVENT_MODULE, /* module type */
|
NGX_EVENT_MODULE, /* module type */
|
||||||
NULL, /* init master */
|
NULL, /* init master */
|
||||||
ngx_epoll_module_init, /* init module */
|
NULL, /* init module */
|
||||||
NULL, /* init process */
|
NULL, /* init process */
|
||||||
NULL, /* init thread */
|
NULL, /* init thread */
|
||||||
NULL, /* exit thread */
|
NULL, /* exit thread */
|
||||||
|
@ -339,9 +341,11 @@ ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (NGX_HAVE_FILE_AIO)
|
#if (NGX_HAVE_FILE_AIO)
|
||||||
|
|
||||||
ngx_epoll_aio_init(cycle, epcf);
|
ngx_epoll_aio_init(cycle, epcf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (NGX_HAVE_EPOLLRDHUP)
|
||||||
|
ngx_epoll_test_rdhup(cycle);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,6 +458,69 @@ ngx_epoll_notify_handler(ngx_event_t *ev)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if (NGX_HAVE_EPOLLRDHUP)
|
||||||
|
|
||||||
|
static void
|
||||||
|
ngx_epoll_test_rdhup(ngx_cycle_t *cycle)
|
||||||
|
{
|
||||||
|
int epfd, s[2], events;
|
||||||
|
struct epoll_event ee;
|
||||||
|
|
||||||
|
epfd = epoll_create(1);
|
||||||
|
|
||||||
|
if (epfd == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
|
"epoll_create() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (socketpair(AF_UNIX, SOCK_STREAM, 0, s) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
|
"socketpair() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ee.events = EPOLLET|EPOLLIN|EPOLLRDHUP;
|
||||||
|
|
||||||
|
if (epoll_ctl(epfd, EPOLL_CTL_ADD, s[0], &ee) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
|
"epoll_ctl() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (close(s[1]) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
|
"close() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
events = epoll_wait(epfd, &ee, 1, 5000);
|
||||||
|
|
||||||
|
if (events == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
|
"epoll_wait() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) close(s[0]);
|
||||||
|
(void) close(epfd);
|
||||||
|
|
||||||
|
if (events) {
|
||||||
|
ngx_use_epoll_rdhup = ee.events & EPOLLRDHUP;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, NGX_ETIMEDOUT,
|
||||||
|
"epoll_wait() timed out");
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
|
"testing the EPOLLRDHUP flag: %s",
|
||||||
|
ngx_use_epoll_rdhup ? "success" : "fail");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ngx_epoll_done(ngx_cycle_t *cycle)
|
ngx_epoll_done(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
|
@ -950,69 +1017,6 @@ ngx_epoll_eventfd_handler(ngx_event_t *ev)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
|
||||||
ngx_epoll_module_init(ngx_cycle_t *cycle)
|
|
||||||
{
|
|
||||||
#if (NGX_HAVE_EPOLLRDHUP)
|
|
||||||
int epfd, s[2], events;
|
|
||||||
struct epoll_event ee;
|
|
||||||
|
|
||||||
epfd = epoll_create(1);
|
|
||||||
|
|
||||||
if (epfd == -1) {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
||||||
"epoll_create() failed");
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, s) == -1) {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
||||||
"socketpair() failed");
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
ee.events = EPOLLET|EPOLLIN|EPOLLRDHUP;
|
|
||||||
|
|
||||||
if (epoll_ctl(epfd, EPOLL_CTL_ADD, s[0], &ee) == -1) {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
||||||
"epoll_ctl() failed");
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (close(s[1]) == -1) {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
||||||
"close() failed");
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
events = epoll_wait(epfd, &ee, 1, 5000);
|
|
||||||
|
|
||||||
if (events == -1) {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
||||||
"epoll_wait() failed");
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) close(s[0]);
|
|
||||||
(void) close(epfd);
|
|
||||||
|
|
||||||
if (events) {
|
|
||||||
ngx_use_epoll_rdhup = ee.events & EPOLLRDHUP;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, NGX_ETIMEDOUT,
|
|
||||||
"epoll_wait() timed out");
|
|
||||||
}
|
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
|
|
||||||
"testing the EPOLLRDHUP flag: %s",
|
|
||||||
ngx_use_epoll_rdhup ? "success" : "fail");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return NGX_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
ngx_epoll_create_conf(ngx_cycle_t *cycle)
|
ngx_epoll_create_conf(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue