Mercurial > hg > nginx
comparison src/core/ngx_connection.c @ 6218:3096ae76ba47
Workaround for "configuration file test failed" under OpenVZ.
If nginx was used under OpenVZ and a container with nginx was suspended
and resumed, configuration tests started to fail because of EADDRINUSE
returned from listen() instead of bind():
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
nginx: configuration file /etc/nginx/nginx.conf test failed
With this change EADDRINUSE errors returned by listen() are handled
similarly to errors returned by bind(), and configuration tests work
fine in the same environment:
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
More details about OpenVZ suspend/resume bug:
https://bugzilla.openvz.org/show_bug.cgi?id=2470
author | Gena Makhomed <gmm@csdoc.com> |
---|---|
date | Thu, 23 Jul 2015 14:00:03 -0400 |
parents | 4f6efabcb09b |
children | 5e6142609e48 |
comparison
equal
deleted
inserted
replaced
6217:b544f8e0d921 | 6218:3096ae76ba47 |
---|---|
565 } | 565 } |
566 } | 566 } |
567 #endif | 567 #endif |
568 | 568 |
569 if (listen(s, ls[i].backlog) == -1) { | 569 if (listen(s, ls[i].backlog) == -1) { |
570 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, | 570 err = ngx_socket_errno; |
571 "listen() to %V, backlog %d failed", | 571 |
572 &ls[i].addr_text, ls[i].backlog); | 572 /* |
573 * on OpenVZ after suspend/resume EADDRINUSE | |
574 * may be returned by listen() instead of bind(), see | |
575 * https://bugzilla.openvz.org/show_bug.cgi?id=2470 | |
576 */ | |
577 | |
578 if (err != NGX_EADDRINUSE || !ngx_test_config) { | |
579 ngx_log_error(NGX_LOG_EMERG, log, err, | |
580 "listen() to %V, backlog %d failed", | |
581 &ls[i].addr_text, ls[i].backlog); | |
582 } | |
573 | 583 |
574 if (ngx_close_socket(s) == -1) { | 584 if (ngx_close_socket(s) == -1) { |
575 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, | 585 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
576 ngx_close_socket_n " %V failed", | 586 ngx_close_socket_n " %V failed", |
577 &ls[i].addr_text); | 587 &ls[i].addr_text); |
578 } | 588 } |
579 | 589 |
580 return NGX_ERROR; | 590 if (err != NGX_EADDRINUSE) { |
591 return NGX_ERROR; | |
592 } | |
593 | |
594 if (!ngx_test_config) { | |
595 failed = 1; | |
596 } | |
597 | |
598 continue; | |
581 } | 599 } |
582 | 600 |
583 ls[i].listen = 1; | 601 ls[i].listen = 1; |
584 | 602 |
585 ls[i].fd = s; | 603 ls[i].fd = s; |