comparison src/core/ngx_connection.c @ 7064:ecb5cd305b06

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 11 Jul 2017 19:59:56 +0300
parents ed1101bbf19f
children c0d89f602d08
comparison
equal deleted inserted replaced
7063:0434f71164f4 7064:ecb5cd305b06
471 return NGX_ERROR; 471 return NGX_ERROR;
472 } 472 }
473 473
474 #if (NGX_HAVE_REUSEPORT) 474 #if (NGX_HAVE_REUSEPORT)
475 475
476 if (ls[i].reuseport) { 476 if (ls[i].reuseport && !ngx_test_config) {
477 int reuseport; 477 int reuseport;
478 478
479 reuseport = 1; 479 reuseport = 1;
480 480
481 if (setsockopt(s, SOL_SOCKET, SO_REUSEPORT, 481 if (setsockopt(s, SOL_SOCKET, SO_REUSEPORT,