diff options
| author | Sergey Kandaurov <pluknet@nginx.com> | 2021-07-15 16:28:21 +0300 |
|---|---|---|
| committer | Sergey Kandaurov <pluknet@nginx.com> | 2021-07-15 16:28:21 +0300 |
| commit | 161759443ccf0e800327af130a3c431789259fa4 (patch) | |
| tree | bb51b1f5264ee1a44fb93e8c0341d1470cd5f97b /src/core/ngx_connection.c | |
| parent | 169b27a50b5e91184853bab96d9377b6f82d871c (diff) | |
| parent | 7384cd1f315c51cd9e3b304ea3a68d160a9ee700 (diff) | |
| download | nginx-161759443ccf0e800327af130a3c431789259fa4.tar.gz nginx-161759443ccf0e800327af130a3c431789259fa4.tar.bz2 | |
Merged with the default branch.
Diffstat (limited to 'src/core/ngx_connection.c')
| -rw-r--r-- | src/core/ngx_connection.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 2c0346f6b..974f48c9a 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -495,21 +495,24 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle) return NGX_ERROR; } - if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, - (const void *) &reuseaddr, sizeof(int)) - == -1) - { - ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, - "setsockopt(SO_REUSEADDR) %V failed", - &ls[i].addr_text); + if (ls[i].type != SOCK_DGRAM || !ngx_test_config) { - if (ngx_close_socket(s) == -1) { + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, + (const void *) &reuseaddr, sizeof(int)) + == -1) + { ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, - ngx_close_socket_n " %V failed", + "setsockopt(SO_REUSEADDR) %V failed", &ls[i].addr_text); - } - return NGX_ERROR; + if (ngx_close_socket(s) == -1) { + ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, + ngx_close_socket_n " %V failed", + &ls[i].addr_text); + } + + return NGX_ERROR; + } } #if (NGX_HAVE_REUSEPORT) |
