]> git.kaiwu.me - nginx.git/commitdiff
Events: fixed setting of IP_BIND_ADDRESS_NO_PORT/SO_REUSEADDR.
authorRuslan Ermilov <ru@nginx.com>
Mon, 22 Aug 2016 08:40:10 +0000 (11:40 +0300)
committerRuslan Ermilov <ru@nginx.com>
Mon, 22 Aug 2016 08:40:10 +0000 (11:40 +0300)
The IP_BIND_ADDRESS_NO_PORT option is set on upstream sockets
if proxy_bind does not specify a port.  The SO_REUSEADDR option
is set on UDP upstream sockets if proxy_bind specifies a port.

Due to checking of the wrong port, IP_BIND_ADDRESS_NO_PORT was
never set, and SO_REUSEPORT was always set.

src/event/ngx_event_connect.c

index 30cb59a048b021c9b32476a036fa6fdea058e372..06534ef06a3a312fafbc2f7f97267024bf193d89 100644 (file)
@@ -91,7 +91,7 @@ ngx_event_connect_peer(ngx_peer_connection_t *pc)
 #endif
 
 #if (NGX_HAVE_IP_BIND_ADDRESS_NO_PORT || NGX_LINUX)
-        port = ngx_inet_get_port(pc->sockaddr);
+        port = ngx_inet_get_port(pc->local->sockaddr);
 #endif
 
 #if (NGX_HAVE_IP_BIND_ADDRESS_NO_PORT)