Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGena Makhomed <gmm@csdoc.com>2015-07-23 21:00:03 +0300
committerGena Makhomed <gmm@csdoc.com>2015-07-23 21:00:03 +0300
commit97741382b6f22352413ed5bfb4787cfa74148bdf (patch)
tree07c083a99c79ea6b428429643d58f2b907183c98 /src/core/ngx_connection.c
parent29cebe5d63dc17514da2439b43b537a7780afb05 (diff)
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
Diffstat (limited to 'src/core/ngx_connection.c')
-rw-r--r--src/core/ngx_connection.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 04a365a76..00c5a08e6 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -567,9 +567,19 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
#endif
if (listen(s, ls[i].backlog) == -1) {
- ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
- "listen() to %V, backlog %d failed",
- &ls[i].addr_text, ls[i].backlog);
+ err = ngx_socket_errno;
+
+ /*
+ * on OpenVZ after suspend/resume EADDRINUSE
+ * may be returned by listen() instead of bind(), see
+ * https://bugzilla.openvz.org/show_bug.cgi?id=2470
+ */
+
+ if (err != NGX_EADDRINUSE || !ngx_test_config) {
+ ngx_log_error(NGX_LOG_EMERG, log, err,
+ "listen() to %V, backlog %d failed",
+ &ls[i].addr_text, ls[i].backlog);
+ }
if (ngx_close_socket(s) == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
@@ -577,7 +587,15 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
&ls[i].addr_text);
}
- return NGX_ERROR;
+ if (err != NGX_EADDRINUSE) {
+ return NGX_ERROR;
+ }
+
+ if (!ngx_test_config) {
+ failed = 1;
+ }
+
+ continue;
}
ls[i].listen = 1;