Mercurial > hg > nginx
comparison src/event/modules/ngx_epoll_module.c @ 6541:282448777dc2
Events: changed ngx_epoll_test_rdhup() to use existing epollfd.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 18 May 2016 15:57:29 +0300 |
parents | a01e400dd4a1 |
children | c93e57ba301b |
comparison
equal
deleted
inserted
replaced
6540:a01e400dd4a1 | 6541:282448777dc2 |
---|---|
461 #if (NGX_HAVE_EPOLLRDHUP) | 461 #if (NGX_HAVE_EPOLLRDHUP) |
462 | 462 |
463 static void | 463 static void |
464 ngx_epoll_test_rdhup(ngx_cycle_t *cycle) | 464 ngx_epoll_test_rdhup(ngx_cycle_t *cycle) |
465 { | 465 { |
466 int epfd, s[2], events; | 466 int s[2], events; |
467 struct epoll_event ee; | 467 struct epoll_event ee; |
468 | |
469 epfd = epoll_create(1); | |
470 | |
471 if (epfd == -1) { | |
472 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
473 "epoll_create() failed"); | |
474 return; | |
475 } | |
476 | 468 |
477 if (socketpair(AF_UNIX, SOCK_STREAM, 0, s) == -1) { | 469 if (socketpair(AF_UNIX, SOCK_STREAM, 0, s) == -1) { |
478 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 470 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
479 "socketpair() failed"); | 471 "socketpair() failed"); |
480 return; | 472 return; |
481 } | 473 } |
482 | 474 |
483 ee.events = EPOLLET|EPOLLIN|EPOLLRDHUP; | 475 ee.events = EPOLLET|EPOLLIN|EPOLLRDHUP; |
484 | 476 |
485 if (epoll_ctl(epfd, EPOLL_CTL_ADD, s[0], &ee) == -1) { | 477 if (epoll_ctl(ep, EPOLL_CTL_ADD, s[0], &ee) == -1) { |
486 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 478 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
487 "epoll_ctl() failed"); | 479 "epoll_ctl() failed"); |
488 return; | 480 return; |
489 } | 481 } |
490 | 482 |
492 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 484 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
493 "close() failed"); | 485 "close() failed"); |
494 return; | 486 return; |
495 } | 487 } |
496 | 488 |
497 events = epoll_wait(epfd, &ee, 1, 5000); | 489 events = epoll_wait(ep, &ee, 1, 5000); |
498 | 490 |
499 if (events == -1) { | 491 if (events == -1) { |
500 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 492 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
501 "epoll_wait() failed"); | 493 "epoll_wait() failed"); |
502 return; | 494 return; |
503 } | 495 } |
504 | 496 |
505 (void) close(s[0]); | 497 (void) close(s[0]); |
506 (void) close(epfd); | |
507 | 498 |
508 if (events) { | 499 if (events) { |
509 ngx_use_epoll_rdhup = ee.events & EPOLLRDHUP; | 500 ngx_use_epoll_rdhup = ee.events & EPOLLRDHUP; |
510 | 501 |
511 } else { | 502 } else { |