Welcome! Log In Create A New Profile

Advanced

[nginx] Core: disabled SO_REUSEPORT when testing config (ticket #1300).

Maxim Dounin
October 17, 2017 09:08AM
details: http://hg.nginx.org/nginx/rev/05bd1baabf87
branches: stable-1.12
changeset: 7138:05bd1baabf87
user: Maxim Dounin <mdounin@mdounin.ru>
date: Tue Jul 11 19:59:56 2017 +0300
description:
Core: disabled SO_REUSEPORT when testing config (ticket #1300).

When closing a socket with SO_REUSEPORT, Linux drops all connections waiting
in this socket's listen queue. Previously, it was believed to only result
in connection resets when reconfiguring nginx to use smaller number of worker
processes. It also results in connection resets during configuration
testing though.

Workaround is to avoid using SO_REUSEPORT when testing configuration. It
should prevent listening sockets from being created if a conflicting socket
already exists, while still preserving detection of other possible errors.
It should also cover UDP sockets.

The only downside of this approach seems to be that a configuration testing
won't be able to properly report the case when nginx was compiled with
SO_REUSEPORT, but the kernel is not able to set it. Such errors will be
reported on a real start instead.

diffstat:

src/core/ngx_connection.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -473,7 +473,7 @@ ngx_open_listening_sockets(ngx_cycle_t *

#if (NGX_HAVE_REUSEPORT)

- if (ls[i].reuseport) {
+ if (ls[i].reuseport && !ngx_test_config) {
int reuseport;

reuseport = 1;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Core: disabled SO_REUSEPORT when testing config (ticket #1300).

Maxim Dounin 351 October 17, 2017 09:08AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 208
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready