Mercurial > hg > nginx-quic
comparison 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 |
comparison
equal
deleted
inserted
replaced
6541:282448777dc2 | 6542:c93e57ba301b |
---|---|
475 ee.events = EPOLLET|EPOLLIN|EPOLLRDHUP; | 475 ee.events = EPOLLET|EPOLLIN|EPOLLRDHUP; |
476 | 476 |
477 if (epoll_ctl(ep, EPOLL_CTL_ADD, s[0], &ee) == -1) { | 477 if (epoll_ctl(ep, EPOLL_CTL_ADD, s[0], &ee) == -1) { |
478 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 478 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
479 "epoll_ctl() failed"); | 479 "epoll_ctl() failed"); |
480 return; | 480 goto failed; |
481 } | 481 } |
482 | 482 |
483 if (close(s[1]) == -1) { | 483 if (close(s[1]) == -1) { |
484 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 484 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
485 "close() failed"); | 485 "close() failed"); |
486 return; | 486 s[1] = -1; |
487 } | 487 goto failed; |
488 } | |
489 | |
490 s[1] = -1; | |
488 | 491 |
489 events = epoll_wait(ep, &ee, 1, 5000); | 492 events = epoll_wait(ep, &ee, 1, 5000); |
490 | 493 |
491 if (events == -1) { | 494 if (events == -1) { |
492 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 495 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
493 "epoll_wait() failed"); | 496 "epoll_wait() failed"); |
494 return; | 497 goto failed; |
495 } | 498 } |
496 | |
497 (void) close(s[0]); | |
498 | 499 |
499 if (events) { | 500 if (events) { |
500 ngx_use_epoll_rdhup = ee.events & EPOLLRDHUP; | 501 ngx_use_epoll_rdhup = ee.events & EPOLLRDHUP; |
501 | 502 |
502 } else { | 503 } else { |
505 } | 506 } |
506 | 507 |
507 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, | 508 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
508 "testing the EPOLLRDHUP flag: %s", | 509 "testing the EPOLLRDHUP flag: %s", |
509 ngx_use_epoll_rdhup ? "success" : "fail"); | 510 ngx_use_epoll_rdhup ? "success" : "fail"); |
511 | |
512 failed: | |
513 | |
514 if (s[1] != -1 && close(s[1]) == -1) { | |
515 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
516 "close() failed"); | |
517 } | |
518 | |
519 if (close(s[0]) == -1) { | |
520 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
521 "close() failed"); | |
522 } | |
510 } | 523 } |
511 | 524 |
512 #endif | 525 #endif |
513 | 526 |
514 | 527 |